- 新建空白文件夹
- 存放创建
vue
插件的文件 - 打开终端至文件夹路径执行
npm init
初始化package.json
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help init` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (myui)
version: (1.0.0) 0.0.3
description: Q的UI框架
entry point: (Demo.js) index.js
test command:
git repository:
keywords: demo 学习
author: Q
license: (ISC)
About to write to E:\WEB\Vue3\myui\package.json:
{
"name": "blairq_ui",
"version": "0.1.0",
"description": "Q的UI框架",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"npm",
"UI"
],
"license": "ISC"
}
- 注册
npm
账号 (需翻墙) - 执行
npm login
输入第4
步创建的账密以及邮箱 - 执行
npm publish
发布 - 更改内容后需要重新发布时需要更新版本号
关于UI
名称: @
符号是私有的,不能有/
等特殊字符
- 安装
npm install blairq_ui@0.0.6 --save
这里使用@版本号
指定版本 - 在
main.js
中引入即可
import myui from 'blairq_ui'
createApp(App).use(store).use(router).use(myui).use(demo, {a: 'aaa'}).mount('#app')
- 在组件中直接使用即可