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) {
  console.log(value)
  console.log(this.$refs["refSubCat"].getCheckedNodes()[0].label)
},
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章