Loading

el-tree默认选中并高亮

        <el-tree ref="myTree" :accordion="true" :data="treeData" :default-expanded-keys="[defaultTreeKeys]" :current-node-key="defaultTreeKeys" children="bridgePositionName" node-key="code" :props="defaultProps" @node-click="handleNodeClick" highlight-current></el-tree>
data () {
    return {
 treeData: [],
      defaultTreeKeys: '',
      defaultProps: {
        children: 'children',
        label: 'name'
      },
    }
}


 this.defaultTreeKeys = data[0].children[0].children[0].code
 this.$nextTick(() => {
    this.$refs.myTree.setCurrentKey(this.defaultTreeKeys)
 })

posted @ 2022-02-25 14:19  资深if-else侠  阅读(416)  评论(0编辑  收藏  举报