我正在使用 https://github.com/posva/unplugin-vue-router#readme 创建路由。 (通过 vitesse 模板)
/hi/asd 和 /hi/asd/other 与 /hi/:name 的视图匹配,基于该文件中的视图内容。
我正在使用的文件夹结构:
src/pages (folder)
src/pages/hi (folder)
src/pages/hi/[name] (folder)
src/pages/hi/[name]/other.vue
src/pages/hi/[name].vue
src/pages/[...all].vue
src/pages/about.md
src/pages/index.vue
src/pages/README.md
为什么与other.vue不匹配?
路由按照定义的顺序进行匹配。 /hi/:name 路由在 /hi/:name/other 路由之前定义,因此它始终会首先匹配。
解决 只需在路由 /hi/:name 之前定义路由 /hi/:name/other 即可。 我希望这会有所帮助。