ant -design vue a-tree 树形控件

话不多说,先上代码。

<a-tree
      v-if="this.treeData && this.treeData.length > 0"
       ref="tree"
       :treeData="treeData"
        :defaultExpandedKeys="expandedKeys"
         :defaultSelectedKeys="expandedKeys"
         @select="treeSelect"
         :title="title"
       >
       <a-icon slot="switcherIcon" type="down" />
</a-tree> 
<script>
import {getTreeDate, queryTreeDate,DelDate} from "@api/api"
data() { return { treeData: [], }; },
created() {
  this.printList(this.$route.query.spaceid);
  this.queryBody(this.$route.query.contentid);
},
treeSelect(selectedKeys,e) {
  //获取面包屑
  this.breadList = [];
  // console.log("这是啥",e.node.parent);
  this.title = e.node._props.title
  // this.contentid = e.node.eventKey;
  console.log("这个是key:",e.node.eventKey)
  console.log("这个是key:",e.node.pos)
  this.queryBody(e.node.eventKey);
},
queryBody(id){
  if (id!=null){
    this.$router.push({path:'/knowledge/AllUpdates/Details?contentid='+id+'&spaceid='+this.$route.query.spaceid});
    queryTreeDate({"contentid":id}).then((res) => {
      if (res.success) {
        this.title = res.result.title;
        this.content = res.result.body;
        this.name = res.result.lastName;
        this.lastDate = res.result.lastmoddate;
      }
    })
  }
},
printList(params,params1){
  console.log(params1)
    getTreeDate({"spaceid":params}).then((res) => {
      if (res.success) {
        this.treeData = res.result;
        console.log(params,params1)
        this.expandedKeys=[this.$route.query.contentid];
        console.log(this.expandedKeys);

      }
    });
},
  }
};
</script>

 

posted @ 2021-12-13 18:03  南屿博客  阅读(3726)  评论(0编辑  收藏  举报