Vue-JS材料设计与TypeScript
我正在尝试将Vue JS材质设计与TypeScript结合使用,但不支持开箱即用。在GitHub问题之后,我一直在尝试添加一个自定义模块,但没有成功。 我的应用程序是使用Vue-JS材料设计与TypeScript,typescript,vue.js,vue-material,Typescript,Vue.js,Vue Material,我正在尝试将Vue JS材质设计与TypeScript结合使用,但不支持开箱即用。在GitHub问题之后,我一直在尝试添加一个自定义模块,但没有成功。 我的应用程序是使用vue create My app命令创建的 我在src中创建了一个新文件:types/vue material/index.d.ts: declare module 'vue-material' { import _Vue from "vue"; export function M
vue create My app
命令创建的
我在src中创建了一个新文件:types/vue material/index.d.ts
:
declare module 'vue-material' {
import _Vue from "vue";
export function MdButton(Vue: typeof _Vue, options?: any): void
export function MdContent(Vue: typeof _Vue, options?: any): void
export function MdTabs(Vue: typeof _Vue, options?: any): void
}
我添加了类型根并从tsconfig
中排除了文件夹:
{
"compilerOptions": {
// ...
"typeRoots": [
"src/types",
"node_modules/@types"
]
},
// ...
"exclude": [
"node_modules",
"src/types"
]
}
但我在尝试导入VueMaterial
时仍然遇到错误:
import { MdButton } from 'vue-material';
我做错了什么
Could not find a declaration file for module 'vue-material'. 'C:/.../my-app/node_modules/vue-material/dist/vue-material.js' implicitly has an 'any' type.
Try `npm install @types/vue-material` if it exists or add a new declaration (.d.ts) file containing `declare module 'vue-material';`