Alternative ideographical analysis of WeChat applet DOM operation

This example describes the alternative ideas of WeChat applet DOM operation. Share to you for your reference, the details are as follows:

WeChat applet cannot operate DOM, which means that various habitual methods in JS must change a way to achieve

Attempts After the class, the effect can be achieved with the {{}} variable binding in the case.

1. Implementing the display and hide of View

DATA setting variable in JS

Bottomhidden1: “Block”

Then set

bindtap

Wait, JS defines the function of the event, use this.setdata to modify the bottomhidden1 variable is None or block, to display the BOTTOM1 in the above, display / hide the control

Second, implementation of the PlaceHolder in Input, when it is cleared, when the focus is cleared

1. In JS, set the variable PriceHodler: “Please enter the price”,
2. We can set the value of two Function control variables PriceHodler (which adds a method to implement the display and disappearance of the icon in the input box, so the variable Clearimg is set in DATA)
   
DISPLAYIMG: Function () {var imgdisplay = “block”; var holderdisplay = “”; this.setdata ({Clearimg: IMGDisplay,PriceHodler: HolderDisplay,}}}}}} hiddenimg: function () {var imghidden = “none”; var holderhidden = “Please enter the price”; this.SetData ({Clearimg: imghidden, PriceHodler: Holderhidden,})},

Attached: The functional implementation of the input box content delete icon (Variables in JS is also set USDVALUE: NULL

,):
 DOCLEARTEXT: FUNCTION () {this.SetData ({USDValue: null,})}},   

3. Add this Input

       
Here, the priceholderhodler in JS is bound to PlaceHolder, Clearimg Binds on Image of Image, Bindfocus = “DisplayImg”

bindblur = “hiddenimg” will control the value of the value of the first two variables, bindtap = “docleartext” will control the Value of the Input Wispired Everyone WeChat applet development is helpful.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment