WeChat small program dynamically adds instance code of the View component

In the Web, we dynamically add DOM, you can use jQuery methods, very simple. How to achieve the following needs in the WeChat applet.


Among them, the number of miles represents the distance from the local line (this is not important); to be implemented is to click the increase route, there will be more lines, delete the way Less one line.

Analysis: Added and deleted the same structure, just the quantity is different, so consider the loop, represented by a list, increase the list Push, and delete one from the list POP.

 Departure                          increase pathway   delete pathway      Because the addition deletion is the same structure, I constructed a class Detail to represent this view        SetPlace: Function (e) {let index = parseint (e.currenttarget.id.replace); "Place-", ") Let Place = E.Detail.Value; let info = this.data.info; info.details [index] .placename = place; this.setData ({INFO: INFO});}, setNumber: Function (E) {let index = parseint (e.currenttarget.id.replace ("Number-", ")); Let Number = E.Detail.Value; Let info = this.data.info; info; info.details [index] .number = number; this.setdata ({info: info});}, 

  The above is the instance code of the WeChat applet to introduce the WeChat applet, I hope to help everyone. If you have any questions, please leave a message, small The newspaper will reply to everyone in time. Thank you very much for your support of Tumi Cloud Website!  
© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment