Micro-letter event binding applet ---

Event Category :

tap: click event;

longtap: Long press event;

touchstart: touch-;

touchend: Touch the end;

touchcansce: Cancellation touch;

Event binding :

bind binding;

catch binding; (able to prevent the event from bubbling)

For example: bind click event bindtap

page.wxml file

<button bindtap="btnclick"></button>

page.js file

Copy the code
// Get Application Examples 
const = getApp App () 
Page ({ 
  Data: { 
    text: "Hello", 
    onoff: to false 
  }, 
  btnClick: function () { 
      the console.log ( '123'); 
      var = onoff this.data .onOff; 
      this.setData ({text: "Hello", onoff:! onoff}); 
  } 
})
Copy the code

 Detailed event :( type type; timestamp timeStamp; event source component target; the current event currentTarget; touch points touches)

For example: Print a click event

display:

currentTarget: are we click on this view;

target: Our view is that this goal;

This view may be to add a id:

effect:

In the bubbling event: currentTarget and the target is inconsistent; currentTarget we bound components, target is a component of the incident;

currentTarget inside the dataset is no data. This is for the convenience we added our custom attributes:

can be seen:

By clicking on the event, you can get to the property of this space, which can facilitate our logic.

This will be very useful

Other events and call app.js inside the event under the project call:

 //index.js
// Get Application Examples 
const = getApp App () 
Page ({ 
  Data: { 
    text: 'button', 
  }, 
  btnClick: function () { 
    var = that the this; 
    the console.log ( 'good'); 
    that.btnchange () ; // call other event items 
    app.clickBtn (); app.js inside the event // call 
  }, 
  btnchange: function () { 
    console.log ( 'yes'); 
  } 
})

 

Guess you like

Origin www.cnblogs.com/wzb0228/p/11540689.html