Solve the problem that there is a switchable or input element inside the parent element, and the problem of directly jumping to the page after clicking (preventing event bubbling)

1. Problem description

Click each item to jump to the page, but when you want to click the drop-down box, it will also jump, so you can’t choose it.
insert image description here

2. Solutions

You need to know that this is caused by event bubbling triggering the click event of the parent element to jump to the page, so event bubbling should be prevented.

<view class="container" @click.stop="stopClick($event)">
	<uni-data-select
	:clear="false"
	  v-model="value"
	  :localdata="roadRange"
	  @change="change"
	></uni-data-select>
</view>
// 阻止下拉框事件冒泡
stopClick(e) {
    
    
	e.stopPropagation()
},

Guess you like

Origin blog.csdn.net/kwroi/article/details/128022540