但是用路由跳转到页面时,只会在第一次跳转触发created和mounted钩子,如果想要多次跳转同个路由界面又要重新触发created和mounted钩子则需要加入以下语句:
<router-view :key="key"></router-view>
computed: {
key() {
return this.$route.name !== undefined? this.$route.name + +new Date(): this.$route + +new Date()
}
},
在 router-view上加上一个唯一的key就可以了