当前位置:网站首页>The use of El cascader and the solution of error reporting
The use of El cascader and the solution of error reporting
2022-07-05 23:42:00 【SwJieJie】
Problem description :
scene : Some types have no data , At this time cascader Of options yes [ ], The drop-down box is empty . If you choose a type , Get cascader The data of , stay cascader Select a piece of data , Replacement type , If there is no such data, an error will be reported 
This is in use element ui Medium cascader Error reports that appear
The reason is not clear for the time being , Personal understanding may be that the data source has not been updated in time , and vue It's data driven , So I added a monitor , And give cascader Bind a key, In this way, as long as the data source changes ,key Just change , Just re render
terms of settlement 1:
If there is no data, it will cascader Set to non editable
<el-cascader
:options="cascaderOption"
:props="props"
:disabled="optionsChanged"
v-model="cascaderValue"
collapse-tags
:placeholder="showPlaceholder"
/>
And directly return, Do not load drop-down nodes
getCascader() {
this.cascaderValue= []
getCascader(this.type).then(response => {
if(response.data.data.length === 0){
this.optionsChanged = true
this.showPlaceholder = ' No scope temporarily '
return
}
this.cascaderOption = response.data.data
});
}
terms of settlement 2: By binding unique key,key Just change , Just re render
<el-cascader
:key="keyValue" //keyValue stay data In the definition of , The initial value is 0
clearable
:props="propsObj"
v-model="value"
:options="options"
>
</el-cascader>
watch: {
options(newVal) {
this.keyValue++ // As long as the data source changes , change keyValue Value , To achieve the effect of re rendering
}
},
边栏推荐
- Différence entre hors bande et en bande
- 4 points tell you the advantages of the combination of real-time chat and chat robots
- 20220703 周赛:知道秘密的人数-动规(题解)
- MySQL replace primary key delete primary key add primary key
- Brushless drive design -- on MOS drive circuit
- Use mapper: --- tkmapper
- 芯源&立创EDA训练营——无刷电机驱动
- Switching power supply buck circuit CCM and DCM working mode
- Go language implementation principle -- map implementation principle
- asp.net弹出层实例
猜你喜欢

Redis高可用——主从复制、哨兵模式、集群

Research notes I software engineering and calculation volume II (Chapter 1-7)

如何获取localStorage中存储的所有值

Live tiktok shop 2022 latest gameplay card slot overseas live e-commerce new traffic

Neural structured learning - Part 3: training with synthesized graphs

5. Logistic regression

Part III Verilog enterprise real topic of "Niuke brush Verilog"

Rasa 3. X learning series -rasa 3.2.1 new release

JVM details

进击的技术er——自动化
随机推荐
STM32__ 06 - single channel ADC
AsyncSocket长连接棒包装问题解决
GFS Distributed File System
2022.6.20-6.26 AI行业周刊(第103期):新的小生命
[SQL] SQL expansion languages of mainstream databases (T-SQL, pl/sql, pl/pgsql)
How to insert data into MySQL database- How can I insert data into a MySQL database?
如何让同步/刷新的图标(el-icon-refresh)旋转起来
UVA11294-Wedding(2-SAT)
UVA – 11637 Garbage Remembering Exam (组合+可能性)
CIS基准测试工具kube-bench使用
做自媒体影视短视频剪辑号,在哪儿下载素材?
Use mapper: --- tkmapper
SpreadJS 15.1 CN 与 SpreadJS 15.1 EN
orgchart. JS organization chart, presenting structural data in an elegant way
如何获取localStorage中存储的所有值
UART Application Design and Simulation Verification 2 - TX Module Design (Stateless machine)
How to improve eloquence
21.PWM应用编程
Rsync remote synchronization
如何提升口才