zoukankan      html  css  js  c++  java
  • Vue--组件Ant- 树形结构菜单

     <template>
    <!--        checkable-节点前添加复选框       -->
                  <a-tree
                    defaultExpandAll
                    :autoExpandParent="true"
                    :treeData="treeData"
                    @select="this.onSelect"
                  />
                </template>
    
    data () {
      return {
        // expandedKeys: ['0-0-0', '0-0-1'], // 受控展开指定的树节点
        autoExpandParent: true, // 是否自动展开父节点
        // checkedKeys: ['0-0-0'], // 受控选中的树节点
        // selectedKeys: [], //(受控)设置选中的树节点
        treeData: [{
          title: '队员:',
          key: '0-0',
          children: []
        }],
    
      getPeopleTree(this.queryParam)
          .then(res => {
            if (res.code && res.code !== 200) {
              this.$message.error(res.message)
            }
            if (res.data !== null) {
              this.peopleTreeData = res.data[0].course_list // 训练数据
              this.treeData[0].title = res.data[0].member // 训练人名字
              for (var i = 0; i < res.data[0].course_list.length; i++) {
                var dict = { title: '', key: '' }
                dict.title = res.data[0].course_list[i].course_name + '-' + res.data[0].course_list[i].course_times
                dict.key = res.data[0].course_list[i].course_id
                this.treeData[0].children.push(dict)
              }
              // console.log('最后的数据' + JSON.stringify(this.treeData))
              // 训练课程id
              // console.log('训练课程id' + res.data[0].course_list[0].course_id)
            } else {
              this.peopleTreeData = []
              this.treeData[0].title = '暂无记录'
            }
            this.loading = false
          })
          .catch((error) => {
            console.log(error)
            if (error.message === 'timeout of 6000ms exceeded') {
              this.$message.error('网络超时')
            }
            this.loading = false
          })
      })
    },
    onSelect (selectedKeys, info) {
      // console.log('点击的人的信息' + JSON.stringify(selectedKeys[0]))
      this.xunlian = selectedKeys[0]
      const getparam = {
        course_id: selectedKeys[0],
        user_id: this.queryParam.user_id
      }
    

      

  • 相关阅读:
    操作系统设计与实现(二)
    SpringCloud(八)Consul的微服务注册
    图的实现(邻接矩阵)及DFS、BFS
    SpringCloud(七)服务注册之Consul的简介和原理
    Mybatis笔记目录(6天)
    Mybatis学习笔记——day02
    C语言教程Day01
    Linux C/C++方向开发(13周学习路线)
    基于Java的实验室预约管理系统
    基于Android的高校学生考勤系统的设计与实现
  • 原文地址:https://www.cnblogs.com/fdxjava/p/11670385.html
Copyright © 2011-2022 走看看