vue项目iview树形控件怎么样使用?
Admin 2021-10-18 群英技术资讯 2045 次浏览
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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
目录@ ~ 相对路径 路径别名设置项目设置src相对路径为@第一步 创建vue.config.js文件第二步 添加代码@ ~ 相对路径 路径别名设置./这是相对路径的意思,同级目录。../上级目录。@/这是webpack设置的路径别名。在build/webpack.base.conf这个文件里面设置了@具体指的是什么在
众所周知javascript语言中只提供了几种基本类型的数据类型,而二叉树是一种数据结构,在一些查询等操作中能提供较好的性能,这篇文章主要给大家介绍了关于利用JS实现二叉树遍历算法的相关资料,需要的朋友可以参考下
这篇文章主要为大家介绍了Vue3插槽Slot实现原理详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
因产品需求和UI样式调整,本文主要实现elementUI下拉选项加多选框的示例代码,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
JavaScript怎样做缓动动画?使用JavaScript原生定时器就可以实现动画的缓动效果,实现的原理其实很简单,也就是通过定时器修改边距达到移动动画效果,那么具体怎样做呢?下面我们来详细的了解看看。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008