Chr*_*els 9 vue.js vue-router vuejs3 vue-router4
在带有路由器 4 的 vue 3 中,该类router-link-active不再为我工作。如果您与 位于同一页面上,router-link-exact-active但不位于任何子页面上,则该类会出现。
例如,链接获取了/test上的<router-link :to="{ name: 'test'}">test</router-link>类router-link-active和类,但/test/2上没有它们router-link-exact-active
{
path: '/test',
name: 'test',
component: Test
},
{
path: '/test/2',
name: 'test-2',
component: Test2
},
Run Code Online (Sandbox Code Playgroud)
真实示例: https ://codesandbox.io/s/vue-router-4-reproductive-forked-zcb7y
谢谢,如有任何想法或建议
Chr*_*els 26
我错过了https://github.com/vuejs/rfcs/blob/master/active-rfcs/0028-router-active-link.md#unlated-but-similiar-routes,它有点隐藏。显示的 RouterView 解决方法工作正常。这是我的例子:
import { h } from 'vue'
import { RouterView } from 'vue-router'
const routes = [
{
path: '/test',
component: { render: () => h(RouterView) },
children: [
{
path: '',
name: 'test',
component: Test
},
{
path: '2',
name: 'test-2',
component: Test2
}
]
}
]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5381 次 |
| 最近记录: |