vue组件开发上传到npm

1)安装vue-cli
npm install -g @vue/[email protected]
报错处理
https://blog.csdn.net/qq_19309473/article/details/116550844?utm_medium=distribute.pc_aggpage_search_result.none-task-blog-2aggregatepagefirst_rank_ecpm_v1~rank_v31_ecpm-3-116550844.pc_agg_new_rank&utm_term=-g+install+npm+vue-cli%404&spm=1000.2123.3001.4430

vue create vue-demo
最终结构如下:
vue组件开发上传到npm_第1张图片
package.js 增加

 "dist": "vue-cli-service build --target lib --name zjj-das-flowable src/components/index.js --dest dist",

组件安装index.js

import Vue from "vue";
import FieldSets from './FieldSets.vue'
import HelloWorld from "./HelloWorld.vue";

const Components = {
    FieldSets,HelloWorld
};

Object.keys(Components).forEach(name => {
    Vue.component(name, Components[name]);
});

export default Components;

执行
npm run dist
vue组件开发上传到npm_第2张图片

cd dist
npm init -y
修改name与版本等信息

{
  "name": "zjj-das-flowable",
  "version": "1.1.0",
  "description": "",
  "main": "zjj-das-flowable.umd.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

npm useradd
npm publish
引用
在main.js中加入

import flowable from  "zjj-das-flowable";
Vue.use(flowable)
或
import "zjj-das-flowable"

App.vue




                    
                    

你可能感兴趣的:(vue,javascript,docker,git)