diff --git a/example/pages/switch/index.js b/example/pages/switch/index.js
index b691471e..2e431537 100644
--- a/example/pages/switch/index.js
+++ b/example/pages/switch/index.js
@@ -11,26 +11,27 @@ Page(Object.assign({}, Zan.Switch, {
},
},
- handleZanSwitchChange(e) {
- var componentId = e.componentId;
- var checked = e.checked;
+ syncChange(e, data) {
+ this.setData({
+ sync: {
+ checked: data.checked
+ }
+ });
+ },
- if (componentId == 'sync') {
- // 同步开关
+ asyncChange(e, data) {
+ this.setData({
+ async: {
+ loading: true
+ }
+ });
+ setTimeout(() => {
this.setData({
- [`${componentId}.checked`]: checked
+ async: {
+ loading: false,
+ checked: data.checked
+ }
});
- } else if (componentId == 'async') {
- // 异步开关
- this.setData({
- [`${componentId}.loading`]: true
- });
- setTimeout(() => {
- this.setData({
- [`${componentId}.loading`]: false,
- [`${componentId}.checked`]: checked
- });
- }, 500);
- }
+ }, 500);
}
}));
diff --git a/example/pages/switch/index.json b/example/pages/switch/index.json
index a13542b6..63223203 100644
--- a/example/pages/switch/index.json
+++ b/example/pages/switch/index.json
@@ -1,3 +1,7 @@
{
- "navigationBarTitleText": "Switch 开关"
+ "navigationBarTitleText": "Switch 开关",
+ "usingComponents": {
+ "zan-switch": "/packages/switch/index",
+ "zan-panel": "/packages/panel/index"
+ }
}
diff --git a/example/pages/switch/index.wxml b/example/pages/switch/index.wxml
index 96c97e3f..81e4131d 100644
--- a/example/pages/switch/index.wxml
+++ b/example/pages/switch/index.wxml
@@ -4,20 +4,16 @@
SWITCH
- 同步开关
-
-
-
+
+
+
- 异步开关
-
-
-
+
+
+
- 开关不可用
-
-
-
-
+
+
+
diff --git a/packages/switch/README.md b/packages/switch/README.md
index 4b95da1b..80ef8073 100644
--- a/packages/switch/README.md
+++ b/packages/switch/README.md
@@ -5,13 +5,13 @@
```json
{
"usingComponents": {
- "zan-switch": "/packages/Panel/panel"
+ "zan-switch": "/packages/switch/index"
}
}
```
### 代码演示
-可以在页面任意位置上使用 zan-popup 标签。通过 show 可以控制弹窗是否展示
+=======
```html