Recently writing Mini Program with mpvue, is there a similar way to manipulate / get dom elements in Mini Program?

to implement a list, add an active class when you click on each item.

liactive

can"t e.currentTarget get the current element? Adding styles has no effect. The format of the output is also different from the previous one

it is not clear whether there is a similar way to operate dom in WeChat Mini Programs. Looking forward to replying ~ Thank you very much?

Mar.02,2021

Why are you operating dom?


the core of a framework like Mini Program and Vue is the binding of template and data, rather than directly manipulating DOM.
you can add a selected attribute to each item selectarr , and then bind it to your style class : class= "{{item.selected}}" to handle the selected value of each item in the click event.


to add a class, you can use a ternary expression, class= "{{'active':curIndex==index}}".
Mini Program provides a method to manipulate dom, https://developers.weixin.qq..
but do not manipulate dom without necessary conditions.

Menu