【发布时间】:2019-10-02 11:59:49
【问题描述】:
我在html中的路由器是
<div>
<transition name="slide-fade">
<router-view :key="$route.fullPath"></router-view>
</transition>
</div>
Vue.js 代码:
this.$router.push({ path : this.$route.matched[0].path , query: Object.assign(this.$route.query, { id: r.jo }) }).then(function(o){
console.error(o);
this.showObj.mode='edit';
}).catch(function(e){
console.error(e);
_this.onQueryChange({ newQuery : { id: r.jo }, replaceAll : false });
_this.showObj.mode='edit';
});
即使在添加 :key="$route.fullPath" 之后,如果我更改 url 中的查询,我仍然会出错
错误消息:
NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated", message: "Navigating to current location ("/contest/fast?id=k0uwjji35741hb") is not allowed", stack: "Error↵ at new NavigationDuplicated (https://unp…lare.com/ajax/libs/vue/2.6.10/vue.min.js:6:11384)"}
message: "Navigating to current location ("/aa/bb?id=j3j3") is not allowed"
name: "NavigationDuplicated"
_name: "NavigationDuplicated"
stack: "Error↵ at new NavigationDuplicated (https://unpkg.com/vue-router/dist/vue-router.js:1980:16)↵ at HashHistory.confirmTransition (https://unpkg.com/vue-router/dist/vue-router.js:2096:20)↵ at HashHistory.transitionTo (https://unpkg.com/vue-router/dist/vue-router.js:2040:10)↵ at HashHistory.replace (https://unpkg.com/vue-router/dist/vue-router.js:2481:12)↵ at https://unpkg.com/vue-router/dist/vue-router.js:2798:24↵ at new Promise (<anonymous>)↵ at VueRouter.replace (https://unpkg.com/vue-router/dist/vue-router.js:2797:14)↵ at a.showDetails
任何允许在 url 中更改查询的建议,例如 ?id
【问题讨论】:
标签: vue.js vuejs2 vue-router