Prevent mpvue small program change event bubbling

Solution: change to an element or component is bound to add another event @ click.stop points to an empty function to prevent bubbling

Note: This method is mainly used mpvue, @ click.stop vue is blocked in the click event bubbling method. If the native applet should add catchtap binding to binding element or component change events in an empty function

This is a problem encountered when using mpvue development of small programs, projects need to reference picker selector assembly applet, click picker found in the selector triggers a change event that will trigger the click event the outer layer of the parent element picker selector (Project We need to implement a click jump module, while requiring a child element within a selector function module)

Vue start by looking at the documents and small program documentation, find the two methods, namely, catch the prefix vue .stop prevent bubbling and applets, but by testing found to change or add events directly .stop catch of no use

Final selection of the online search to a compromise approach, the picker to select additionally add a click event (or to the selector of the parent element to add click event), add new events added to prevent bubbling click method, the click event pointing to an empty function. This also solves the problem of indirect change event bubbling

If you there is a better way, welcome message

Reproduced in: https: //www.jianshu.com/p/e52f824323a2

Guess you like

Origin blog.csdn.net/weixin_33804582/article/details/91296710