diff --git a/dist/switch-cell/index.js b/dist/switch-cell/index.js index ccc0b276..7581323d 100644 --- a/dist/switch-cell/index.js +++ b/dist/switch-cell/index.js @@ -1,20 +1,31 @@ Component({ + behaviors: ['wx://form-field'], + options: { addGlobalClass: true }, properties: { title: String, - checked: Boolean, border: Boolean, loading: Boolean, disabled: Boolean, + checked: { + type: Boolean, + observer(value) { + this.setData({ value }); + } + }, size: { type: String, value: '26px' } }, + attached() { + this.setData({ value: this.data.checked }); + }, + methods: { onChange(event) { this.triggerEvent('change', event.detail); diff --git a/packages/switch-cell/README.md b/packages/switch-cell/README.md index 6ebde625..3b00f52a 100644 --- a/packages/switch-cell/README.md +++ b/packages/switch-cell/README.md @@ -61,6 +61,7 @@ Page({ | 参数 | 说明 | 类型 | 默认值 | |-----------|-----------|-----------|-------------| +| name | 在表单内提交时的标识符 | `String` | - | | checked | 开关状态 | `Boolean` | - | | title | 左侧标题 | `String` | `''` | | loading | 是否为加载状态 | `Boolean` | `false` | diff --git a/packages/switch-cell/index.js b/packages/switch-cell/index.js index ccc0b276..7581323d 100644 --- a/packages/switch-cell/index.js +++ b/packages/switch-cell/index.js @@ -1,20 +1,31 @@ Component({ + behaviors: ['wx://form-field'], + options: { addGlobalClass: true }, properties: { title: String, - checked: Boolean, border: Boolean, loading: Boolean, disabled: Boolean, + checked: { + type: Boolean, + observer(value) { + this.setData({ value }); + } + }, size: { type: String, value: '26px' } }, + attached() { + this.setData({ value: this.data.checked }); + }, + methods: { onChange(event) { this.triggerEvent('change', event.detail);