互联网技术 · 2024年2月14日

element中el-cascader通过props定制value、label、children

当我们使用el-cascader组件时,有时后台返回的数据和我们组件对应的值不一样,很多人会选择把后台返回的值给循环遍历处理一遍,把值改成value、label、children,但是实际不必如果。通过props属性轻松配置,话不多说,直接上代码:

后台返回的数据:

[{

id: 1,

name: 指南,

child: [{

id: shejiyuanze,

name: 设计原则,

child: [{

id: yizhi,

name: 一致

}]

}]

vue文件

<el-cascader< p=””>

:options=”cityList”

:props=”{ value: id,label: name,children: child}”

v-model=”selectedOptions”

@change=”handleChange”>

ok,是不是超级简单。如果看不懂的宝宝,你要细品。

文章来源:田珊珊个人博客

来源地址:http://www.tianshan277.com/835.html

OpenMagic API

Need more than content? Move into the product flow.

If you are here for model access, pricing, developer docs, or the future API console, the dedicated product path now lives on api.openmagic.ai.