Vue Router Optional Param

Nov 1, 2020
{
    path: '/places/:urlName?'
}

The following paths are valid

  • /places/
  • /places/singapore/
{
    path: '/news/(page)?/:page(\\d+)?'
}

The following paths are valid

  • /news/
  • /news/page/2

NOTE: /news(/page/)?:page(\\d+)? does not work with error Expected "0" to match "\/page\/", but received "%2Fpage%2F"

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.