checkbox中嵌套select
在项目中有需求是需要在checkbox中包含select下拉框,
//例如:
<el-checkbox label="time">
<span class="mr5">超过</span>
<el-form-item prop="fileMonth">
<el-select v-model="autoClear.fileMonth">
<el-option v-for="item in month" :key="item" :label="item" :value="item">
</el-option>
</el-select>
</el-form-item>个月
</el-checkbox>
以上就是checkbox中包含一个select的结构,虽然实现了,但会有一个问题:在点击select下拉框选值时,会触发checkbox的选中与取消选中。这是因为select的点击事件冒泡到checkbox,因此,需要在select上阻止冒泡。
//在select上定义点击事件,并加上.prevent事件修饰符
//因为这个点击事件主要是利用.prevent组织冒泡,因此preventSuffix这个方法是个空函数,没有其他操作
<el-select v-model="autoClear.fileMonth" @click.native.preven