在歌曲组件中,我有一个其他专辑的列表,所以每当我点击一个时,它应该将我重定向到 /songs/:id。每张专辑都有自己的 id。
这适用于 Home 或任何其他组件,但每当我尝试从 /songs/1 到 /songs/2 时,它都不起作用。URL 发生变化,但网页保持不变。
这是我的路由器 index.js 文件。
import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
Vue.use(VueRouter)
const routes = [
{
path: '/',
name: 'Home',
component: Home,
},
{
path: '/songs/:id',
name: 'Songs',
component: () => import('../views/Songs.vue')
},
{
path: '/videos/:title/:index',
name: 'Videos',
component: () => import('../views/Videos.vue')
}
]
const router = new VueRouter({
mode: 'history',
routes
})
export default router
我在谷歌上搜索了一下,但似乎没有什么对我有用。