我正在构建一个包含产品列表的Nuxt应用程序,然后单击其中一个打开该产品的专用页面。它工作正常。
结构是:
/pages/featured // directory of products
/pages/product/:id/:slug // Dedicated product page
Run Code Online (Sandbox Code Playgroud)
现在我想添加一个新功能:
我希望实现的一个很好的例子是Youpic的 photo 目录。
“产品”列表,完全在带有内部导航的对话框中可见。
我正在查看各种nuxt-routing和vue-router文档以尝试开发它,但我离解决方案还很远。
我在这里看到的一小部分代码看起来与我需要的非常相似,但我不明白我应该如何正确实现它以及如何创建我的 nuxt 自定义路由:
export default {
router: {
extendRoutes (routes, resolve) {
routes.push({
path: '/users/:id',
components: {
default: resolve(__dirname, 'pages/users'), // or routes[index].component
modal: resolve(__dirname, 'components/modal.vue')
},
chunkNames: {
modal: 'components/modal'
}
})
}
}
}
Run Code Online (Sandbox Code Playgroud)