修改进入数据简介时,默认选中当前的菜单栏样式

dev_2022-03-03
e 3 years ago
parent 246f03b458
commit b882a9bc37
  1. 13
      src/views/data/Introduce.vue

@ -2,7 +2,7 @@
<div>
<el-container>
<el-aside width="350px">
<el-tree ref="type" :data="typeList" node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" highlight-current @node-click="typeClick"></el-tree>
<el-tree ref="type" :data="typeList" node-key="id" accordion :default-expanded-keys="defaultActive" :current-node-key="categoryId" :props="defaultProps" :highlight-current="true" @current-change="typeClick"></el-tree>
</el-aside>
<el-main style="padding-top: 0">
@ -101,6 +101,7 @@ export default {
})
}
handleId(res)
console.log(res)
this.typeList = res
// id
@ -109,22 +110,28 @@ export default {
let item = res[0].children[0]
this.categoryId = item.id
this.dataSource = res[0].children[0].dataSource
this.defaultActive = [item.id]
this.defaultActive = [res[0].children[0].id]
// this.defaultActive = [item.id]
this.introduceText = item.introduce
this.introduce = item.introduce
}else{
this.categoryId = res[0].id
this.dataSource = res[0].dataSource
this.defaultActive = [res[0].id]
this.defaultActive = [res[0].children[0].id]
// this.defaultActive = [res[0].id]
this.introduceText = res[0].introduce
this.introduce = res[0].introduce
}
this.$nextTick(() => {
this.$refs.type.setCurrentKey(this.categoryId)
})
}
this.getKeyword()
}).catch(res => {})
},
//
typeClick(data,node){
console.log(data)
this.editing = false
this.categoryId = data.id
this.defaultActive = [data.id]

Loading…
Cancel
Save