[Vuejs]-Nuxt.js routes limit possible parameter options

0👍

Vue-router has fantastic way of dynamic redirects / checks:

const router = new VueRouter({
  routes: [
    { path: '/a', redirect: to => {
      // the function receives the target route as the argument
      // return redirect path/location here.
    }}
  ]
})

You can place route checks into this function and perform any needed validations.

Or… you can use the full power of Vue-router reg-exp and write your path in router.js like this one:

/(clothes|electronics|babies)/*

Leave a comment