vue3+element-plus+ts
1、獲取選中的節(jié)點(diǎn)及其所有上級(jí)
使用cascader組件提供的getCheckedNodes()文章來源地址http://www.zghlxwxcb.cn/news/detail-575025.html
<el-cascader :options="options" :show-all-levels="false" @change="changeCascader" ref="cascader" />
const cascader = ref();
const options = [
{
value: 'fu1',
label: '父1',
type: '父type1',
children: [
{
value: 'zi1',
label: '子1',
type: '子type1',
children: [
{
value: 'sun1',
label: '孫1',
type: '孫type1',
},
{
value: 'sun2',
label: '孫2',
type: '孫type2',
},
],
},
{
value: 'zi2',
label: '子2',
type: '子type2',
},
],
},
{
value: 'fu2',
label: '父2',
type: '父type2',
},
];
const changeCascader = () => {
let nodesInfo = cascader.value.getCheckedNodes();
console.log(nodesInfo);
//賦值
form.storeId = nodesInfo[0].parent.data.value;
form.storeName = nodesInfo[0].parent.data.label;
form.spaceId = nodesInfo[0].data.value;
form.spaceName = nodesInfo[0].data.label;
};
文章來源:http://www.zghlxwxcb.cn/news/detail-575025.html
到了這里,關(guān)于el-cascader級(jí)聯(lián)選擇器那些事的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!