樓主做的是一個三級聯動的城市篩選,后臺給過來的數據并不全是按照label, value, children的key給到我,數據格式但是官方的props只能指到一級,具體指到2-3級我還不沒弄明白。于是 , 需要自己轉換<el-cascader
??:options="options"
??v-model="selectedOptions"
??filterable
??clearable
??:props="props"
??@change="handleAreaChange">
</el-cascader>我自己的思路:將前面兩級的key全部轉換成最后一級props:?{
??value:?'disCode',
??label:?'disName',
??children:?'district'
}方法getGetallareas?()?{
??let?para?=?new?URLSearchParams()
??para.append('userId',?this.userId)
??getallareas(para).then((res)?=>?{
????console.log(res)
????this.options?=?res.data
????let?d?=?[]
????for?(let?i?=?0;?i?<?this.options.length;?i++)?{
??????let?a?=?{}
??????a.disName?=?this.options[i].proName
??????a.disCode?=?this.options[i].proCode
??????a.district?=?this.options[i].cities
??????d.push(a)
??????let?e?=?[]
??????console.log(d)
??????d[i].district.forEach(element?=>?{
????????let?b?=?{}
????????b.disName?=?element.cityName
????????b.disCode?=?element.cityCode
????????b.district?=?element.district
????????e.push(b)
??????})
??????d[i].district?=?e
????}
????this.options?=?d
??})
},效果那么問題來了,我輸入北京搜索好的 完全沒有問題我繼續輸入廣東顯示無匹配數據,然后看看控制臺報了一個 無法讀取toLowerCase的錯誤,然而當我輸入白云的時候,請問踩過這個坑的朋友們有什么解決方案嗎,有的話,請分享一下,拜謝!我自己的備用解決方法將會使用select,,,,
分享一個element-ui級聯選擇器的搜索問題,順便問下有沒有解決方案。
荼酒
2018-04-12 20:16:23