Wechat applet native writing method to pass parameters

 Wechat applet native writing method to pass parameters

 

 

data-xxx custom parameter name, receiving parameter: method (variable name) 

	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
	},

If you need to pass more than one, you can write multiple data-[parameters] to pass

Multiple parameter writing method data-a, data-b, receiving parameter: method (variable name)  

	checkVip:function(event)  {
		let that = this
		console.log(event.currentTarget.dataset.a,'index1')
		console.log(event.currentTarget.dataset.b,'index2')
	},

 It is recommended to use all lowercase names, short and short spelling~

Guess you like

Origin blog.csdn.net/zhangxueyou2223/article/details/132035672