富贵资源网 Design By www.hznty.com

vue+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传给 后台
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。