Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue 3 / Typescript: "Cannot find name" in template variable

In Vue 3 / Typescript, I am getting the following error:

"Cannot find name", when referencing a data variable into the ... area.

How can I solve this?

Please see the attached screenshot.

enter image description here

Many thanks in advance.

like image 797
iknowmagic Avatar asked Nov 14 '22 19:11

iknowmagic


1 Answers

I had a similar issue when I added lang="ts" to the vue file as I'm new to Vue 3 and Typescript. I resolved it by ensuring the following:

export default 

to

export default defineComponent({

in your .vue file.

Ensure you add the import.

import { defineComponent }

Your data should reside in the setup as well.

setup () {
  return {
    loader: false,
    error: false,
    firstTime: false
like image 150
Joshua Coda Avatar answered Dec 24 '22 23:12

Joshua Coda