<el-form-item>
<label>基本属性:</label>
<!-- <el-input v-model="form.name"></el-input> -->
<el-cascader
:options="options"
:props="defaultParams"
clearable
class="el-input"
v-model="ruleForm"
></el-cascader>
</el-form-item>
默认设置很多都可以,但是里面嵌套很多children我没找到,所以解决废了一些时间后解决了这个问题。
options: [{
value: 1,
label: '东南',
children: [{
value: 2,
label: '上海',
children: [
{ value: 3, label: '普陀' },
{ value: 4, label: '黄埔' },
{ value: 5, label: '徐汇' }
]
}, {
value: 7,
label: '江苏',
children: [
{ value: 8, label: '南京' },
{ value: 9, label: '苏州' },
{ value: 10, label: '无锡' }
]
}, {
value: 12,
label: '浙江',
children: [
{ value: 13, label: '杭州' },
{ value: 14, label: '宁波' },
{ value: 15, label: '嘉兴' }
]
}]
}, {
value: 17,
label: '西北',
children: [{
value: 18,
label: '陕西',
children: [
{ value: 19, label: '西安' },
{ value: 20, label: '延安' }
]
}, {
value: 21,
label: '新疆维吾尔族自治区',
children: [
{ value: 22, label: '乌鲁木齐' },
{ value: 23, label: '克拉玛依' }
]
}]
}]
defaultparams:是设置显不显示多选,设置value,value是选择默认显示的,label是页面显示的,children是显示子元素的
defaultParams: {
value: "value", //设置默认值value
label: "label", //设置显示的是什么
children: "children", //设置子元素数组是啥
multiple: true,//多选
},
再用ruleForm选择默认显示的是什么
ruleForm: ["1,2,3"], //默认值选中的1下面的孩子2下面的孩子3
这个默认显示的就是东南 上海 普陀
好的就这样 。