单次调用 push() 时,Vue Router 更新 URl 两次
Vue Router updates URl twice for single call to push()
这个
this.$router.push({ path: '/upload'});
更新浏览器 URL 以...#/upload 正常。但是
this.$router.push( '/edit/file/4' );
在地址栏中短暂闪烁预期的 URL,然后更新为“...#/” - 转换有效,因为我的编辑视图已加载,但我必须按两次返回(一次到 /edit/file/4,一次到我以前的真实状态)而不是一次。
为什么?我怎样才能让它像我期望的那样工作?
我的路由器路由是
routes: [
{
path: '/',
name: 'home',
component: Home,
children:[
{
name: 'upload',
path:'upload',
component:HomeUpload
},
{
name: 'edit-file',
path: 'edit/file/:file_id',
component:HomeUpload,
props: true // or field_id prop not filled in
}
]
}
]
因为模板有
<a @click="edit(page)" href="#">Edit</a></td>
而不是
<a @click="edit(page)">Edit</a></td>
这个
this.$router.push({ path: '/upload'});
更新浏览器 URL 以...#/upload 正常。但是
this.$router.push( '/edit/file/4' );
在地址栏中短暂闪烁预期的 URL,然后更新为“...#/” - 转换有效,因为我的编辑视图已加载,但我必须按两次返回(一次到 /edit/file/4,一次到我以前的真实状态)而不是一次。
为什么?我怎样才能让它像我期望的那样工作?
我的路由器路由是
routes: [
{
path: '/',
name: 'home',
component: Home,
children:[
{
name: 'upload',
path:'upload',
component:HomeUpload
},
{
name: 'edit-file',
path: 'edit/file/:file_id',
component:HomeUpload,
props: true // or field_id prop not filled in
}
]
}
]
因为模板有
<a @click="edit(page)" href="#">Edit</a></td>
而不是
<a @click="edit(page)">Edit</a></td>