• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

vue+iview使用树形控件的具体使用

vue 搞代码 4年前 (2022-01-08) 15次浏览 已收录 0个评论

这篇文章主要介绍了vue+iview使用树形控件的具体使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

vue+iview使用树形控件

1.开发环境 vue+iview

2.电脑系统 windows10专业版

3.在使用 vue+iview开发的过程中,我们经常会使用 iview的树形控件,在这里我就简单的做一个分享,希望对你有所帮助!

4.在template中添加如下代码:

  

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中添加如下代码:

 chentr<i>本文来源gaodai$ma#com搞$代*码*网</i>eelick(data) { console.log(data); console.log("点击了"); console.log(data[0].chenshow); }, //注意:参数 data,在点击的时候可以获取到后台的数据,这个数据是来自后台的,在实际开发中,我们可以 利用 data,把后台需要的id传给 后台 

以上就是vue+iview使用树形控件的具体使用的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:vue+iview使用树形控件的具体使用

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址