|
@@ -39,13 +39,14 @@ export default {
|
|
|
props: [],
|
|
|
data() {
|
|
|
return {
|
|
|
+ isPath: false
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
...mapGetters('layout', ['sidebarClosed', 'breadcrumb'])
|
|
|
},
|
|
|
methods: {
|
|
|
- ...mapMutations('layout', ['setSidebarClosed']),
|
|
|
+ ...mapMutations('layout', ['setSidebarClosed','setSidebarSelected']),
|
|
|
windwoResize() {
|
|
|
// 窗口大小发生变化时
|
|
|
let clientWidth = `${document.documentElement.clientWidth}`
|
|
@@ -60,24 +61,25 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
findPathInArray(arr, path) {
|
|
|
- console.log()
|
|
|
arr.forEach(ele => {
|
|
|
if(ele.path == path) {
|
|
|
- return true
|
|
|
+ this.isPath = true
|
|
|
}
|
|
|
if(ele.children) {
|
|
|
- return this.findPathInArray(ele.children, path)
|
|
|
+ this.findPathInArray(ele.children, path)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
- $route: {
|
|
|
+ "$route": {
|
|
|
handler: function(route, oldVal){
|
|
|
- console.log('**************************')
|
|
|
- console.log(menus)
|
|
|
- console.log(route.path,'guoguo');
|
|
|
- console.log(this.findPathInArray(menus,route.path))
|
|
|
+ let path = route.path
|
|
|
+ this.isPath = false;
|
|
|
+ this.findPathInArray(menus,path)
|
|
|
+ if(this.isPath) {
|
|
|
+ this.setSidebarSelected(path)
|
|
|
+ }
|
|
|
},
|
|
|
// 深度观察监听
|
|
|
deep: true
|