[Vuejs]-How to access $route in js file using VueJS

1👍

Define the user as a function and pass the menuid as parameter, then define breadCrumb as computed that returns the user function with this.$route.params.menuid as argument :

const user = menuid => [{ title: 'User List', link: `/${menuid}/user` }]

then:

export default {
  computed: {
    breadCrumb() {
      return user(this.$route.params.menuid)
    },
  },
} 

Leave a comment