The cascader cascading selector in element-ui does not provide a method to directly obtain the currently selected Object in the official website documentation. Here, special attention should be paid to the version of element-ui. Different versions require different methods.
Before version 2.7.0
You can use this.$refs['cascader'].currentLabels to get the selected node.
<el-cascader ref="groupList" :options="checkGroup" v-model="addForm.plot_group" @change="handleChange" :filterable="true" style="width: 100%" />
//Get node label content
handleChange(value) {
let nodesInfo = this.$refs["groupList"].currentLabels;
},
Because the installed element-ui version is higher than version 2.7.0, there is no screenshot of the node content obtained by currentLabels.
Version 2.7.0 and later
You can use this.$refs['cascader'].getCheckedNodes() to get the checked nodes, currentLabels was removed in version 2.7.
<el-cascader ref="groupList" :options="checkGroup" v-model="addForm.plot_group" @change="handleChange" :filterable="true" style="width: 100%" />
// Get all the content of the selected node
handleChange(value) {
let nodesInfo = this.$refs["groupList"].getCheckedNodes();
},
//Get the content of the last level of the selected node (for example: get label)
handleChange(value) {
let nodesInfo = this.$refs["groupList"].getCheckedNodes()[0].label;
},