微信小程序原生写法传递参数
data-xxx 自定义参数名 ,接收参数:方法(变量名)
checkVip:function(event) {
let that = this
console.log(event,'event')
console.log(event.currentTarget.dataset.idx,'index')
let index = Number(event.currentTarget.dataset.idx)
// // this.isChek = index
let checkMoney = that.data.vipList[index].price
console.log(checkMoney,'this.checkMoney')
that.setData({
isChek: event.currentTarget.dataset.idx,
checkMoney:that.data.vipList[index].price
})
// this.pay_Money = price
},
如果需要传递多个,可以写多个data-[参数]的方式进行传递
多个参数写法 data-a ,data-b, 接收参数 :方法(变量名)
checkVip:function(event) {
let that = this
console.log(event.currentTarget.dataset.a,'index1')
console.log(event.currentTarget.dataset.b,'index2')
},
建议采用全小写命名,简短短拼~