VueJS/Typescript相关问题

 

 

1.找不到模块“../views/main.vue”或其相应的类型声明。

 

In the src folder add the file shims-vue.d.ts with the following content :

 

Vue 2 :

declare module "*.vue" {
  import Vue from 'vue'
  export default Vue
}

 

Vue 3:

declare module '*.vue' {
  import type { DefineComponent } from 'vue'
  const component: DefineComponent<{}, {}, any>
  export default component
}

 

转载自:

https://www.it1352.com/2283329.html

 

2.定义全局变量或者方法

使用的方法1

 

转载自:

http://t.zoukankan.com/zjjDaily-p-12931624.html

 

posted @ 2021-11-10 17:34  泠风lj  阅读(97)  评论(0编辑  收藏  举报