文章目录
1、 npm init生成package.json,然后写好组件
2、 登陆npm官网(需要翻墙)
3、 npm login链接远程服务器
4、 发布,在文件夹下运行npm publish
版本号相同、@符号是私有的、不能有斜杠等特殊符号
5、使用npm install–savexxx 安装使用
6、完整目录与代码:
{
"name": "zhubaui", // 包名
"version": "1.0.0",
"description": "ZhuBa的VueUI",
"main": "index.js", // 入口文件
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "ZhuBa",
"license": "ISC"
}
import ZBButton from "./compontents/ZBButton.vue"
import ZBSwiper from "./compontents/ZBSwiper.vue"
// 放置到数组中便于导入
const compontents = [ZBButton, ZBSwiper];
export default {
install: (app, options) => {
// 通过循环一个个导入循环
compontents.forEach((item) => {
app.compontents(item.name, item)
})
}
}
// 1、 npm init 生成package.json 写好组件
// 2、 登陆npm官网(需要翻墙)
// 3、 npm login 链接远程服务器
// 4、 发布,在文件夹下运行 npm publish
// 版本号相同、@符号是私有的、不能有斜杠等特殊符号
// 5、使用 npm install --save xxx安装使用
// ZBButton
<template>
<button>ZhuBa的Button组件</button>
</template>
<script>
export default { name: "ZBButton" };
</script>
// ZBSwiper
<template>
<button>ZhuBa的轮播组件</button>
</template>
<script>
export default { name: "ZBSwiper" };
</script>