cr vc-switch

pull/1040/head
tangjinzhou 2019-06-30 20:43:46 +08:00
parent b380b30e90
commit e444ca1c7e
1 changed files with 4 additions and 4 deletions

View File

@ -42,14 +42,14 @@ export default {
}); });
}, },
methods: { methods: {
setChecked(checked) { setChecked(checked, e) {
if (this.disabled) { if (this.disabled) {
return; return;
} }
if (!hasProp(this, 'checked')) { if (!hasProp(this, 'checked')) {
this.stateChecked = checked; this.stateChecked = checked;
} }
this.$emit('change', checked); this.$emit('change', checked, e);
}, },
handleClick(e) { handleClick(e) {
const checked = !this.stateChecked; const checked = !this.stateChecked;
@ -59,10 +59,10 @@ export default {
handleKeyDown(e) { handleKeyDown(e) {
if (e.keyCode === 37) { if (e.keyCode === 37) {
// Left // Left
this.setChecked(false); this.setChecked(false, e);
} else if (e.keyCode === 39) { } else if (e.keyCode === 39) {
// Right // Right
this.setChecked(true); this.setChecked(true, e);
} }
}, },
handleMouseUp(e) { handleMouseUp(e) {