当前位置:网站首页>The submenu of the el-cascader cascade selector is double-clicked to display the selected content
The submenu of the el-cascader cascade selector is double-clicked to display the selected content
2022-08-10 05:49:00 【Why can't I get enough to eat?】
Recently encountered such a mistake, the submenu needs to be clicked twice before its value is displayed in the selector bar, and one click can get the value, but it is not displayed. The code is as follows:
It should be noted here that by binding the listening option switching event @change="handleChange" to the cascading selector, when we switch options, we can get the selected options from the first level to the following methods in this method.All value arrays of the last level,
Example: The array of cascade selectors is as follows
{
partKey:'a',
partName:'First-level equipment',
children:[
{
PartKey:'a1',
PartName:'Secondary device 1',
},
partKey:'a2',
partName:'Secondary device 2',}
]
}// The secondary device 2 is selected at this time
Then this.checkedAllValue=['a','a2']
// The nodeName here is the ref attribute defined in the cascade selector, and checkedValue is the method of refs itself, just use it directlythis.checkedAllValue = this.$refs["nodeName"].checkedValue;
But we only use the value of the currently selected level in the end, so it is changed to the following, Remember to define the variable in data!
this.checkedPartKey = this.$refs["nodeName"].checkedValue[1];
Then traverse the array bound by the current cascade selector in the handleChange method, and use the forEach() method to match the currently selected checkedPartKey with the partKey of each item in the array.The partName of an item is assigned to the checkedPartName defined in data, and it is assigned to partName when the form is finally submitted, so that the partName carried when sending the request is the partName value of the selected option submenu in the array of the above example.
If you don't do this, and write this.dataForm.partName as the others when sending the request, the passed value is an array. I can't remember the passed value, but it doesn't meet the requirements.
p>// Listen for the event that the cascading selector option changeshandleChange() {this.checkedPartKey = this.$refs["nodeName"].checkedValue[1];this.nodeNameOptions.forEach((item, index, nodeNameOptions) => {let itemArr = item.children;itemArr.forEach((item1, index, itemArr) => {if (this.checkedPartKey == item1.partKey) {this.checkedPartName = item1.partName;}});});},
-----------------------------------------------------------------------------------------------------------------------------------------
I suddenly thought that instead of defining the variable checkedPartName, you can directly make this.dataForm.partName=partName of the matching item after matching it.
边栏推荐
- opencv
- 去中心化和p2p网络以及中心化为核心的传统通信
- cesium listens to map zoom or zoom to control whether the content added on the map is displayed
- ORACLE系统表空间SYSTEM占满无法扩充表空间问题解决过程
- 使用Tenserboard可视化深度学习训练过程
- Batch add watermark to pictures batch add background zoom batch merge tool picUnionV4.0
- 网络安全6
- impdp 导入数据
- matlab中的常用的类型转换
- 定时器(setInterval)的开启与关闭
猜你喜欢
随机推荐
清览题库--C语言程序设计第五版编程题解析(1)
tinymce富文本编辑器
cesium 旋转图片
Reprint fstream, detailed usage of ifstream
ORACLE系统表空间SYSTEM占满无法扩充表空间问题解决过程
操作表 函数的使用
利用PyQt5制作YOLOv5的GUI界面
链读 | 最新最全的数字藏品发售日历-07.28
小记录:Pytorch做深度学习必要加载的包
pygame学习计划(1)
Using sqlplus to operate database in shell script
行盒子的盒模型
智能合约和去中心化应用DAPP
网络安全7
常用类 BigDecimal
pytorch框架学习(1)网络的简单构建
使用Tenserboard可视化深度学习训练过程
Collection工具类
基本比例尺标准分幅编号流程
来亲自手搭一个ResNet18网络