routesFolder with param #272
-
Hello, My files structure :
My VueRouter definition : VueRouter({
extensions: ['.vue'],
dts: 'src/typed-router.d.ts',
routesFolder: [
'src/pages',
{
src: 'src/pages/localized',
path: ':lang/',
},
],
}), Questions :
Thanks ! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You can pass a custom regexp to params (vue router): <script setup>
const route = useRoute()
watch(() => route.params.lang, (lang, oldLang) => {
})
</script> (imports omitted) |
Beta Was this translation helpful? Give feedback.
You can pass a custom regexp to params (vue router):
path: ':lang(en|es|fr)'
. You could also validate them in a beforeEach guard. That allows to have a dynamic list rather than one set at built time, it depends on what you need.You detect changes to the param with a watcher, like any other reactive property in vue.
(imports omitted)