Vue Router Optional Param

November 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"

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.