程序员の奇妙冒险

返回
vue Vue
2025-05-15 08:50 阅读:343 评论:0

vform3 源码编译打包其他项目引入使用

vform3源码编译引入项目 遇到的问题 当通过import引入vform3时遇到以下错误 image image 安装依赖 于是改变方式通过npm install将编译后的文件以依赖包方式加载到项目中,操作如下: 在项目中创建vform3-builds文件夹,将vform3打包生成的dist文件夹

vform3源码编译引入项目

遇到的问题

  • 当通过import引入vform3时遇到以下错误 image

image

安装依赖

  • 于是改变方式通过npm install将编译后的文件以依赖包方式加载到项目中,操作如下:
  • 在项目中创建vform3-builds文件夹,将vform3打包生成的dist文件夹复制到此文件夹中
  • 并在vform3-builds文件夹中创建package.json文件,添加以下内容
1
2
3
4
5
6
7
8
9
10
11
12
{
"name": "vform3-builds",
"version": "3.0.10",
"private": false,
"main": "dist/designer.umd.js",
"keywords": [
"variant-form",
"vform",
"element-ui",
"form-designer"
]
}
  • 项目根目录下的package.json引入依赖,如下
1
2
3
4
"dependencies": {
// 这里指定vform3存放路径
"vform3-builds": "file:./vform3-builds"
},
  • 执行npm install 安装依赖
  • 此时可以通过以下方式在main.ts中引入插件
1
2
3
4
5
import ElementPlus from 'element-plus' //element-plus
import 'element-plus/dist/index.css' //element-plus
 
import VForm3 from 'vform3-builds' //VForm3
import 'vform3-builds/dist/designer.style.css' //VForm3
  • 到此已经可是正常使用插件了
评论 (0)
暂无评论 来抢沙发吧~