[Vuejs]-Is it possible to access route params within props to set a default?

2👍

You can actually pass a function as the default property:

props: {
  name: {
    type: String,
    required: true,
    default() {
      return 'user ID: ' + this.$route.params.user_id;
    }
  }
}

Leave a comment