鍍金池/ 問答/HTML/ vue+element-ui里面,Cascader 級(jí)聯(lián)選擇器如何使用prop里

vue+element-ui里面,Cascader 級(jí)聯(lián)選擇器如何使用prop里面的children選項(xiàng)?

在使用element-ui里面,使用Cascader 級(jí)聯(lián)選擇器時(shí)候,可以調(diào)用到children數(shù)據(jù),但是無法選中,這種情況要如何解決?

Html代碼

  <el-cascader :options="options" v-model="selectedOptions" @change="handleChange" placeholder="請選擇實(shí)驗(yàn)室" class="content" :props="props">

js代碼

 props: {
        value: "name",
        label: "name",
        children: "items"
      },
      
      // 這里是調(diào)用接口的數(shù)據(jù)
 beforeCreate() {
    this.axios
      .post(`/api/services/app/tenant/GetTreeTenant`)
      .then(response => {
        console.log(response.data.result);
        this.options = response.data.result;
      })
      .catch(function(error) {
        console.log(error);
      });
  },

這里是接口返回的數(shù)據(jù),主選項(xiàng)是name, children是這個(gè)items下面的name
圖片描述圖片描述

這是實(shí)際效果,無法選中其數(shù)據(jù)
圖片描述

這是我期待的效果,選中數(shù)據(jù)并顯示
圖片描述

回答
編輯回答
生性

最后一級(jí)items 不應(yīng)該是空數(shù)組

2018年2月4日 01:20
編輯回答
陪妳哭

這種情況考慮數(shù)據(jù)沒有綁定成功,你是在beforeCreate里面請求的數(shù)據(jù),建議在created里面獲取數(shù)據(jù)


還有啊 你這個(gè)里面還有items 而且是空的 導(dǎo)致會(huì)有三級(jí)的選項(xiàng),但第三級(jí)選項(xiàng)里面沒有數(shù)據(jù)

2017年3月18日 11:33