Cascader 级联选择器 数据渲染
通过 :options=“options” 映射,让每一级都可以选择(选项前会有圆圈可勾选)设置属性 :props="{ checkStrictly: true }"
1、点击后下拉框自动收起实现
设置每次监听值变化的时候,把 dropDownVisible 属性设置为 false 即可。(这个属性,官网根本没有说… )
html部分:
<el-form-item label="菜单"><el-cascaderref="cascader"v-model="menuIDList":options="menuData":props="{value: 'id', label: 'name', children: 'child', checkStrictly:true}":placeholder="$t('operation.select')"style="width:70%;"clearable></el-cascader>
</el-form-item>
data() {return {menuDialog: false, // 菜单弹框selectedData: [], // 表格里已选条目数据dataList: [], // 表格数据选中的idform: {admin_menu_id: '',route_id_list: ''},menuIDList: [] // 菜单选择数据}},watch: {menuIDList() {if (this.$refs.cascader) {this.$refs.cascader.dropDownVisible = false}}}