Skip to content

Commit b5533b3

Browse files
kokorolisendya
authored andcommitted
fix: lifecycle hooks
1 parent 42b386e commit b5533b3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/Menu/menu.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ export default {
4040
return keys
4141
}
4242
},
43-
created () {
43+
// created () {
44+
// this.updateMenu()
45+
// },
46+
/**
47+
* updateMenu 在 created 周期中被调用,他先于 render 函数
48+
* 因此 renderMenuItem 函数中添加 meta: {hidden: true} 是 updateMenu 执行完成后再改变的
49+
* 在添加 meta 后需要重新调用一下 updateMenu 来改变 selectedKeys 的值
50+
* */
51+
mounted () {
4452
this.updateMenu()
4553
},
4654
watch: {
@@ -73,6 +81,7 @@ export default {
7381
}
7482
},
7583
updateMenu () {
84+
console.log('this updateMenu methods')
7685
const routes = this.$route.matched.concat()
7786
console.log('updateMenu: routes -> ', routes)
7887
console.log('this.$route', this.$route)
@@ -154,6 +163,7 @@ export default {
154163
)
155164
}
156165
},
166+
157167
render () {
158168
const { mode, theme, menu } = this
159169
const props = {

0 commit comments

Comments
 (0)