Skip to content

restricting parameters #216

Closed Answered by posva
Theo-Steiner asked this question in Questions and Help
Discussion options

You must be logged in to vote

You use definePage() to override the path and override the regexp of the parameter:

<script setup lang="ts>
definePage({
  path: '/:fruit(watermelon|strawberry)',
})
</script>

If the match is more complex, you will need to setup a navigation guard so you can freely do any check:

<script setup>
definePage({
  beforeEnter(to) {
    if (Number.isNaN(Number(to.params.id))) {
      console.log('invalid param id', to.params.id)
      return false
    }
  },
})
<script>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Theo-Steiner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants