diff --git a/.eslintignore b/.eslintignore index 8d1a11e8d..72bf17083 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ lib/ dist/ node_modules/ +build/ diff --git a/docs/examples/switch.md b/docs/examples/switch.md index 268bee214..400912c95 100644 --- a/docs/examples/switch.md +++ b/docs/examples/switch.md @@ -12,11 +12,7 @@ export default { }, methods: { updateState(newState) { - console.log('changing'); this.switchState = newState; - }, - handleClick() { - alert('click'); } } }; @@ -26,12 +22,15 @@ export default { @component switch { padding: 0 15px 15px; - @descendent sample { - margin: 0 15px; + @descendent wrapper { + margin: 30px; + width: 100px; + float: left; + text-align: center; } @descendent text { - margin-right: 20px; + margin: 20px 0; } } } @@ -44,9 +43,14 @@ export default { :::demo 样例代码 ```html
- Switch state: {{switchStateText}} - - +
+ +
{{switchStateText}}
+
+
+ +
OFF, DISABLED
+
``` @@ -55,17 +59,16 @@ export default { export default { data() { return { - switchState: false + switchState: true }; }, computed: { switchStateText() { - return this.switchState ? 'on' : 'off'; + return this.switchState ? ' ON' : 'OFF'; } }, methods: { updateState(newState) { - console.log('changing'); this.switchState = newState; } } @@ -77,7 +80,7 @@ export default { | 参数 | 说明 | 类型 | 默认值 | 可选值 | |-----------|-----------|-----------|-------------|-------------| -| checked | 开关状态 | boolean | false | true,false | -| loading | loading状态 | boolean | false | true,false | -| disabled | 禁用状态 | boolean | false | true,false | +| checked | 开关状态 | boolean | false | true, false | +| loading | loading状态 | boolean | false | true, false | +| disabled | 禁用状态 | boolean | false | true, false | | onChange | 回调 | function | function(){} | - | diff --git a/packages/button/src/button.vue b/packages/button/src/button.vue index 6bb783e34..7f423ae2a 100644 --- a/packages/button/src/button.vue +++ b/packages/button/src/button.vue @@ -32,15 +32,13 @@ * @example * 按钮 */ + +const allowedSize = ['mini', 'small', 'normal', 'large']; +const allowedType = ['default', 'danger', 'primary']; + export default { name: 'z-button', - methods: { - handleClick(e) { - this.$emit('click', e); - } - }, - props: { disabled: Boolean, loading: Boolean, @@ -49,23 +47,14 @@ export default { type: String, default: 'default', validator(value) { - return [ - 'default', - 'danger', - 'primary' - ].indexOf(value) > -1; + return allowedSize.indexOf(value) > -1; } }, size: { type: String, default: 'normal', validator(value) { - return [ - 'mini', - 'small', - 'normal', - 'large' - ].indexOf(value) > -1; + return allowedType.indexOf(value) > -1; } } } diff --git a/packages/switch/src/switch.vue b/packages/switch/src/switch.vue index f1eb7c706..0b8413dce 100644 --- a/packages/switch/src/switch.vue +++ b/packages/switch/src/switch.vue @@ -1,12 +1,12 @@