如何在打字稿中使用Vue.use()?

时间:2018-01-18 09:14:04

标签: typescript vue.js vuetify.js

我想在typescript中使用vuetify插件。 在文档(https://vuetifyjs.com/vuetify/quick-start)中,它表示使用Vue.use(),但在typescript中有这样的错误:

"error TS2345: Argument of type '{}' is not assignable to parameter of type 'undefined'."
Vue.use(Vuetify, {
  theme: {
    primary: '#3f51b5',
    secondary: '#b0bec5',
    accent: '#8c9eff',
    error: '#b71c1c'
  }
})

2 个答案:

答案 0 :(得分:0)

在tsconfig.json中添加" compilerOptions"部分:

"module": "es2015"

答案 1 :(得分:0)

对于正在寻找该问题解决方案的任何人:使用VueJs + Typescript时,您想要使用Vuetify或VeeValidate之类的插件。

例如VeeValidate请执行以下操作:

import Vue from "vue";

import VeeValidate from "vee-validate";

Vue.use(VeeValidate.install, { });