vue中使用watch监听$route 无效问题
2020-11-26 本文已影响0人
子语喵
路由:
{ // 首页
path: '/',
name: 'index',
component: resolve => require(['@/views/index/index'], resolve),
},
监听:
watch: {
'$route'(to, from) {
console.log(to, from)
}
},
{ // 首页
path: '/',
name: 'index',
component: resolve => require(['@/views/index/index'], resolve),
children: [
{
path: 'user',
name: 'user',
component: resolve => require(['@/views/index/user'], resolve),
},
{
path: 'userName',
name: 'userName',
component: resolve => require(['@/views/index/userName'], resolve),
},
]
},