element 的 el-cascade 组件如何获取级联选中label和value值

value 好获取,主要是label,我百度了半天都是说用 this.$refs[关联组件名].currentLabels 可以获取,但是这个方法已经过期了。
还是自己看文档才发现使用 getCheckedNodes 方法的节点获取。完整的 this.$refs["refSubCat"].getCheckedNodes()[0].label

1. 效果

在这里插入图片描述

2. 代码

<el-cascader
   ref="refSubCat"
   :show-all-levels="false"
   :options="allSubCatList"
   :props="subCatProps"
   @change="handleSubCat"
   v-model="subCatValue"
 ></el-cascader>
handleSubCat(value) {
  // 获取value值
  console.log(value)
  // 获取label 值
  console.log(this.$refs["refSubCat"].getCheckedNodes()[0].label)
},
发布了109 篇原创文章 · 获赞 91 · 访问量 33万+

猜你喜欢

转载自blog.csdn.net/qq_36410795/article/details/98730980