1

Say I'm using an imported Vue component: autocomplete

<script>
...
<autocomplete @submit="onSubmit"/>
</script>

...
methods: {
  onSubmit: async(input) => {
     // add user's input to selected
  },
data () {
  return {
    selected: []
  }
},
...

I'm passing in a method for the event handler. How can I give it this context so I can update data with input?

Michael Sun
  • 189
  • 3
  • 10
  • 1
    Methods already have `this` context. What problem are you facing? Try writing `async onSubmit (input) {....`, maybe that helps? – Maarten Veerman Feb 21 '21 at 07:01
  • See linked duplicate. Don't declare component methods with arrow functions. Use a regular function instead (as suggested in comment above). – tony19 Feb 21 '21 at 08:01

0 Answers0