Skip to content

Commit

Permalink
perf: component.on.event配置 ,兼容事件名称不用on开头的写法
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Nov 2, 2023
1 parent 61d449c commit 28ccfa5
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ export default defineComponent({
const events: {
[key: string]: (e: ComponentEventContext) => void;
} = { ...props.events, ...props.on };

_.forEach(events, (value, key) => {
const handler = value;
if (!key.startsWith("on")) {
key = _.camelCase("on_" + key);
}
attrs[key] = ($event: any) => {
return handler({ ...props.scope, $event });
};
Expand Down

0 comments on commit 28ccfa5

Please sign in to comment.