Assign values to the data in Data in the event processing function
Create button in wxml file
<button type="primary" bindtap="btnTapHandler" id="btn">确定</button>
In the corresponding js file
btnTapHandler(e){
this.setData({
count:this.data.count + 1
})
Use setData() to assign values to attributes in data
AppData can see the modified value in the debugger.
So how to pass parameters in the event processing function?
The usage is as follows:
Use the data-* method to pass parameters, * represents the name of the parameter, and the parameter value is passed through mustache.
<button type="primary" bindtap="btnTapHandler" id="btn" data-info="{
{2}}">确定</button>
info will be parsed as parameter name
2 will be parsed as the parameter value
How does input get the input value, use bindinput to bind the event
<input bindinput="inputHandler"></input>
in the .js file
inputHandler:function(e:any){
console.log(e.detail.value);
},
You can see it in the console of the debugger