怎么给el-tree添加两个数组
时间: 2024-05-06 08:19:54 浏览: 28
您可以使用`props`属性来为`el-tree`组件添加两个数组,如下所示:
```html
<template>
<el-tree :data="treeData" :props="treeProps"></el-tree>
</template>
<script>
export default {
data() {
return {
treeData: [/* your tree data */],
array1: [/* your first array */],
array2: [/* your second array */]
};
},
computed: {
treeProps() {
return {
// set your tree props here
/* for example */
label: 'name',
children: 'children',
// add your two arrays as custom props
array1: this.array1,
array2: this.array2
};
}
}
};
</script>
```
在上面的示例中,我们为`el-tree`组件添加了两个自定义属性`array1`和`array2`,并将它们作为`treeProps`属性的一部分传递给`el-tree`组件。现在,您可以在组件中通过`this.$attrs.array1`和`this.$attrs.array2`访问这两个数组。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)