Skip to content
Advertisement

Vue 3 and Typescript – Cannot access data property in a method

Im trying to access my data in a method I am writing, but it does not seem to work. I get an TS2339 Typescript error saying that the property does not exist in the type.

JavaScript

Here is the code for the component:

JavaScript

Advertisement

Answer

to get types inference you should create component instance using defineComponent imported from vue:

JavaScript
Advertisement