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

原文地址:https://www.cnblogs.com/miangao/p/15534501.html