0
我在/entries/12
路由上。在用户点击下一个按钮时,我想在同一个组件上按/entries/13
。vue-router与不同参数相同的路由
代码如下:
//e is the next page number.
this.$router.push({ name: 'Entries', params: { pageNum: e }});
我得到以下错误:
,如果我尝试的作品不同的路线。
整个代码:
<template>
<div class="entries">
<generic-entries @clicked="clicked" ></generic-entries>
</div>
</template>
<script>
import GenericEntriesComp from '@/components/GenericEntriesComp';
export default{
name: 'entries-comp',
components: {genericEntries: GenericEntriesComp},
mounted(){
var params = {id : this.$route.params.pageNum}
this.$store.dispatch("getEntries",params);
},
methods: {
clicked(e){
this.$router.push({ name: 'Entries', params: { pageNum: e.toString() }});
},
loadData(){
var params = {pageNum : this.$route.params.pageNum}
this.$store.dispatch("getEntries", params)
}
},
computed: {
items(){
return this.$store.state.entries
},
},
watch: {
'$route': 'loadData'
}
}
</script>
顺便说一句误差来自:
Vue.config.errorHandler = function (err, vm, info) {
console.error(err);
}
您确定负责该路线的代码是正确和有效的吗?当你手动进入'entry/13'时会发生什么? –
如果您的路线对象包含以下路线,应该可以工作:{path:'/ entry /:pageNum',name:'Entries'}。这是你使用的结构吗? – Joos
@BelminBedak如果我尝试不同的命名路线它的作品。所以,我相信它是。 – serkan