我正在尝试从/checklist/1/item/2
导航到/checklist/2/item/1
与this.$router.push({ name: 'checklistitem', params: { id: this.id, aid: this.aid } });
这会更改浏览器中的URL,但不会加载(呈现)带有新数据的页面。
路由器是用这些
import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
const routes = [
{
path: '/',
name: 'home',
component: HomeView
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
},
{
path: '/checklist/:id',
name: 'checklist',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/AcChecklistsView.vue'),
props: true
},
{
path: '/checklist/:id/item/:aid',
name: 'checklistitem',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ '../views/ChecklistView.vue'),
props: true
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
mode: 'history',
routes
})
export default router
有人知道出了什么问题吗?
谢谢
1条答案
按热度按时间h79rfbju1#
通过传递带有“replace:true”在可选的“to”属性中,所以它会是。