el-tree 树全部展开或收起

绑定属性expanded,树自带方法this.$refs.tree.store.root.expanded,在mounted方法中给树方法赋值expandAll = false,具体代码实现详情如下:

html代码:

html 复制代码
<template>

      <el-tree
                  ref="tree"
                  :data="showDepData"
                  expand-on-click-node="false"
                  :props="{
                    label: 'name'
                  }"
                  node-key="deptId"
                  highlight-current
                  :default-expand-all="expanded"
                  @node-click="changeDepClick"
                >
                  <span slot-scope="{ node, data }">
                    <i
                      v-if="node.level == 1"
                      style="margin-right: 4px"
                      class="wk wk-customer"
                    />{{ data.name }}
                  </span>
                </el-tree>

</template

js代码:

java 复制代码
data(){

return{
expanded:false
}

}

mounted(){
//获取树自带的属性并给他赋值false
this.$refs.store.root.expanded = expanded

}
相关推荐
高级程序源7 分钟前
springboot本地生活服务平台33399-计算机课程设计、毕业设计
vue.js·spring boot·python·mysql·小程序·flask·课程设计
高级程序源12 分钟前
springboot社区旧物回收管理系统25381-计算机课程设计、毕业设计
vue.js·spring boot·python·django·课程设计
高级程序源15 分钟前
springboot大学生体测系统72170-计算机课程设计、毕业设计
java·vue.js·spring boot·后端·python·django·课程设计
谢亮_vipxieliang20 分钟前
JavaScript this 指向完全指南:调用位置决定一切
开发语言·javascript·ecmascript
Eiceblue36 分钟前
使用 Python 实现 Excel 行列转置(保留单元格样式)
前端·python·excel
WeiXin_DZbishe38 分钟前
基于Node.js的马拉松赛事管理系统的设计与实现-计算机毕设 附源码【课程设计】90211
java·javascript·vue.js·python·php·课程设计
西西学代码1 小时前
像素和颜色之间的转换(Flutter)
前端·javascript·flutter
茶底世界之下1 小时前
羽毛颜色已经很鲜艳,还要继续加色吗?用 Awaking 试一次减饱和
前端·ios·运营
风早爽太1 小时前
Mac 搭建 Vue 开发环境
前端·vue.js
Lank_M1 小时前
Word图片裁剪转HTML失效,转换器各漏读了哪一层
前端