1.0.1 • Published 5 years ago
@ryan-dev/pi-switch v1.0.1
Switch 开关
表示两种相互对立的状态间的切换,多用于触发开/关
使用
npm 方式
1.引入组件
在小程序项目中目录下执行
npm i @ryan-dev/pi-switch --save
2. 开发者工具构建 npm,勾选“使用 npm 模块”,参考 npm 支持 (https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html)
3. 页面 json 文件中加入 usingComponents 字段
{
"usingComponents": {
"pi-switch": "@ryan-dev/pi-switch"
}
}
4. 页面 wxml 中使用该组件
<pi-switch></pi-switch>
源码方式
1.源码下载
git clone https://github.com/go-pi/wechat-pi.git
2.引入组件
将项目下目录src/pi-switch下文件全部复制到小程序组件目录下,例如components/pi-switch
3. 页面 json 文件中加入 usingComponents 字段
修改对应的目录地址
{
"usingComponents": {
"pi-switch": "../components/pi-switch"
}
}