在新的 vue js 项目中找不到模块“vuetify/lib”的声明文件

Ruh*_*ara 10 javascript vue.js vuetify.js

我创建了一个新的 vue 项目,然后我添加了 vuetify,

$ vue create my-app
$ cd my-app
$ vue add vuetify
$ npm run serve
Run Code Online (Sandbox Code Playgroud)

然后我得到了这个错误

ERROR in /home/ruhith/Documents/vue/file upload/fileupload/src/plugins/vuetify.ts(2,21):
2:21 Could not find a declaration file for module 'vuetify/lib'. '/home/ruhith/Documents/vue/file upload/fileupload/node_modules/vuetify/lib/index.js' implicitly has an 'any' type.
  Try `npm install @types/vuetify` if it exists or add a new declaration (.d.ts) file containing `declare module 'vuetify/lib';`
    1 | import Vue from 'vue';
  > 2 | import Vuetify from 'vuetify/lib';
      |                     ^
    3 | 
    4 | Vue.use(Vuetify);
    5 | 
Version: typescript 3.8.3
Time: 2774ms
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么?这是 vuetufy 中的错误吗?

Kir*_*kov 8

您需要将 vuetify 的类型添加到 tsconfig.json 中,如下所示:

// tsconfig.json
{
  "compilerOptions": {
    "types": ["vuetify"]
  }
}
Run Code Online (Sandbox Code Playgroud)

取自这里的常见问题解答:https : //vuetifyjs.com/en/getting-started/frequently-asked-questions/#questions

  • 这对我来说并不能解决问题。我已经有了类型中的“vuetify”。 (4认同)

小智 -4

更改文件node_modules->vuetify-loader->lib->plugin.js

class VuetifyLoaderPlugin {
  constructor (options) {
    // this.options = options || {}
    this.options = (options) ? options : {}
  }
Run Code Online (Sandbox Code Playgroud)