feat: 评分 事件&动作 修改

This commit is contained in:
liuzedong02 2022-02-21 19:16:30 +08:00
parent 508a4d1d8b
commit bc52b2db91

View File

@ -93,25 +93,19 @@ export default class RatingControl extends React.Component<RatingProps, any> {
}
}
async dispatchChangeEvent(eventName: string, eventData: any = {}) {
const {dispatchEvent, data} = this.props;
const rendererEvent = await dispatchEvent(
eventName,
createObject(data, {
value: eventData,
})
);
return rendererEvent?.prevented ?? false;
}
@autobind
async handleChange(value: any) {
const {onChange} = this.props;
const {onChange, dispatchEvent, data} = this.props;
const prevented = await this.dispatchChangeEvent('change', value);
const rendererEvent = await dispatchEvent('change', createObject(data, {
value
}));
prevented || (onChange && onChange(value));
if (rendererEvent?.prevented) {
return;
}
onChange && onChange(value);
}
render() {