amyees-test-plugin-package
v1.0.0
Published
微信小程序 npm 包 - 组件与 JS 模块
Readme
lite-pos-cashier-mate
微信小程序 npm 包,支持自定义组件和 JS 模块。
安装
npm install lite-pos-cashier-mate在小程序开发者工具中点击 工具 → 构建 npm 后即可使用。
使用
使用自定义组件
在页面的 json 配置中引入:
{
"usingComponents": {
"cashier-mate": "lite-pos-cashier-mate"
}
}在 wxml 中使用:
<cashier-mate title="收银助手" bindtap="onTap" />使用 JS 模块
const { formatAmount, debounce } = require('lite-pos-cashier-mate/utils');
// 格式化金额
formatAmount(1999); // "19.99"
// 防抖
const fn = debounce(() => console.log('debounced'), 300);开发
构建
npm install
npm run build构建产物输出到 miniprogram_dist 目录,符合微信小程序 npm 包规范。
监听开发
npm run watch清理
npm run clean目录结构
├── src/ # 源码
│ ├── index.js # 组件入口
│ ├── index.json
│ ├── index.wxml
│ ├── index.wxss
│ └── utils/ # JS 工具模块
│ └── index.js
├── miniprogram_dist/ # 构建输出
├── tools/
│ └── config.js # 构建配置
├── gulpfile.js
└── package.json添加新组件或模块
- 在
src/下新建目录或文件 - 组件需包含:
.js、.json、.wxml、.wxss - JS 模块只需
.js文件,使用export导出 - 执行
npm run build构建
发布
- 确保已执行
npm run build - 登录 npm:
npm login - 发布:
npm publish
