【发布时间】:2022-01-11 22:28:42
【问题描述】:
我有一个在 Vue.js 3 中制作的项目,使用带有如下配置的 vue-router:
const routes = [
{
path: '/',
name: "home",
component: Home
},
{
path: '/philosophy',
component: philosophy,
children: [{
path: '/',
component: card1
},
{
path: '/card2',
component: card2
},
{
path: '/card3',
component: card3
},
{
path: '/card4',
component: card4
}]
}
]
每张卡片都是通过router-link 指令加载的,在<div> 元素内部,其中有一个rowter-view。
card1 的路径是"/",目的是在用户进入路径“/philosophy”时加载 card1。这在 Vue 2 中工作得很好,但在 Vue 3 中却不行,组件不再加载。
Vue 3 中有什么方法可以让组件card1 被默认加载?
在此先感谢您的帮助。
【问题讨论】:
标签: vue.js vue-router vuejs3 web-frameworks