1

Having a problem trying to access query params.

I can access the query via

this.$attrs.query or this.$route.query.propValue

In the chrome debugger.

When I try to load it I get the one of these errors:

vue.runtime.esm.js?2b0e:4484 Uncaught TypeError: Cannot read property '$attrs' of undefined
vue.runtime.esm.js?2b0e:4484 Uncaught TypeError: Cannot read property '$route' of undefined

Examples of where I am using it in the component:

props: { 
      propValue: {
        type: String,
        default: () => {
          console.log('default')
          return this.$route.query.propValue // this.$attrs.query //
        }
      }
    },
methods: {
      async update() {
        const res = await axios.post('/api/endpoint', {
         valueToSend: this.propValue...
user3738936
  • 822
  • 5
  • 15
  • 1
    Aah.. the arrow function.. `this` inside arrow function is not what you think it is.. Change it to normal function. Don't use arrow functions in Vue instance as much as possible to avoid this confusion. – Mat J Mar 06 '21 at 18:54

0 Answers0