vue项目iview树形控件怎么样使用?
Admin 2021-10-18 群英技术资讯 1408 次浏览
vue项目iview树形控件怎么样使用?在vue项目中, iview的树形控件的使用还是比较多的,因此这篇文章就给大家分享一下 iview的树形控件的用法,感兴趣的朋友就继续往下看吧。
1.开发环境 vue+iview
2.电脑系统 windows10专业版
3.在使用 vue+iview开发的过程中,我们经常会使用 iview的树形控件,在这里我就简单的做一个分享,希望对你有所帮助!
4.在template中添加如下代码:
<Scroll style="width: 100%" height="760"> <Tree @on-select-change="chentreelick" :data="treedata" expand-node ></Tree> </Scroll>
5.在 return 中添加如下代码:
treedata: [ { title: "parent 1", chenshow: false, expand: true, children: [ { title: "parent 1-1", chenshow: false, expand: true, children: [ { title: "leaf 1-1-1", chenshow: true, }, { title: "leaf 1-1-2", chenshow: true, selected: true, }, ], }, { title: "parent 1-2", chenshow: false, expand: true, children: [ { title: "leaf 1-2-1", chenshow: true, }, { title: "leaf 1-2-1", chenshow: true, }, ], }, { title: "parent 1-3", chenshow: false, expand: true, children: [ { title: "leaf 1-3-1", chenshow: true, }, { title: "leaf 1-3-1", chenshow: true, }, ], }, { title: "parent 1-4", chenshow: false, expand: true, children: [ { title: "leaf 1-4-1", chenshow: true, }, { title: "leaf 1-4-1", chenshow: true, }, ], }, { title: "parent 1-5", chenshow: false, expand: true, children: [ { title: "leaf 1-5-1", chenshow: true, }, { title: "leaf 1-5-1", chenshow: true, }, ], }, { title: "parent 1-6", chenshow: false, expand: true, children: [ { title: "leaf 1-6-1", chenshow: true, }, { title: "leaf 1-6-1", chenshow: true, }, ], }, { title: "parent 1-7", chenshow: false, expand: true, children: [ { title: "leaf 1-7-1", chenshow: true, }, { title: "leaf 1-7-1", chenshow: true, }, ], }, { title: "parent 1-8", chenshow: false, expand: true, children: [ { title: "leaf 1-8-1", chenshow: true, }, { title: "leaf 1-8-1", chenshow: true, }, ], }, { title: "parent 1-9", chenshow: false, expand: true, children: [ { title: "leaf 1-9-1", chenshow: true, }, { title: "leaf 1-9-1", chenshow: true, }, ], }, ], }, ],
5-1.注意 这个 return中绑定的数据,可以参考 iview官方文档,地址如下:
https://www.iviewui.com/components/tree
6.在 methods中添加如下代码:
chentreelick(data) {
console.log(data);
console.log("点击了");
console.log(data[0].chenshow);
},
//注意:参数 data,在点击的时候可以获取到后台的数据,这个数据是来自后台的,在实际开发中,我们可以 利用 data,把后台需要的id传给 后台
关于iview树形控件的使用就介绍到这,上述示例具有一定的借鉴价值,感兴趣的朋友可以参考,希望能对大家有帮助,想要了解更多iview树形控件的使用,大家可以关注其它的相关文章。
文本转载自脚本之家
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要为大家介绍了Vue3.2 setup语法糖及Hook函数基本使用示例详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
最近做了一个比较老的vue项目,启动居然各种报错,下面这篇文章主要给大家介绍了关于Vue常见报错以及解决方案的相关资料,文中通过图文介绍的非常详细,需要的朋友可以参考下
这篇文章主要介绍了Vue实现一种简单的无限循环滚动动画的示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
这篇文章主要为大家详细介绍了Vue.js实现图片切换功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
这篇文章主要给大家介绍了关于vue动态菜单、动态路由加载以及刷新踩坑的相关资料,踩的这些坑其实是挺常见的,大家可以看看,避免遇到的时候再踩到同样的坑,需要的朋友可以参考下
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008