我想导入vue-form-generator的源代码,以便对源代码进行一些更改。作为Node和Javascript的新手,我真的不知道我在做什么。有人能指导我完成这些步骤吗?
因为我的Vue项目是Typescript,所以以前在使用npm install vue-form-generator时,我已经创建了vfg.d.ts
declare module "vue-form-generator" {
const VueFormGenerator: any;
export default VueFormGenerator;
}我的main.ts是
import VueFormGenerator from 'vue-form-generator';
Vue.component('VueFormGenerator', VueFormGenerator);现在,我已经将他们的组件中的所有内容复制到我的/src //src/form-generator中,但是不知道如何创建它,所以我可以像以前一样使用它。
发布于 2018-08-01 12:14:39
如果你正在创建你自己的vue-form-generator分支,你也可以在那里添加类型声明。
在您的src/component/form-generator副本中创建文件index.d.ts
const VueFormGenerator: any;
export default VueFormGenerator;没有必要在其中包含declare module ...,因为这个index.d.ts就在index.js的旁边,所以当您将其导入为
import VueFormGenerator from './relative-path-to/form-generator/index';生成的javascript代码将在那里找到index.js。请注意,导入路径必须是相对的,否则,在没有任何路径映射的情况下,它将在node_modules中查找模块,而不是在源代码中查找。
还必须移除项目中对前一个类型声明文件vfg.d.ts的所有引用。
https://stackoverflow.com/questions/51624604
复制相似问题