antd-mini
Version:
antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。
24 lines (22 loc) • 514 B
text/typescript
import mixinValue from '../mixins/value';
import { Component, triggerEvent } from '../_util/simply';
import { SwitchDefaultProps } from './props';
Component({
props: SwitchDefaultProps,
data: null,
methods: {
onChange(e) {
const value = !this.getValue();
if (!this.isControlled()) {
this.update(value);
}
triggerEvent(this, 'change', value, e);
},
},
mixins: [
mixinValue({
valueKey: 'checked',
defaultValueKey: 'defaultChecked',
}),
],
});