提交 d21c8f26 编写于 作者: fxy060608's avatar fxy060608

fix(mp): kebab-case event (#3616)

上级 62c6e09e
import { hasOwn, isArray } from '@vue/shared'
import { hasOwn, isArray, hyphenate } from '@vue/shared'
import {
ComponentOptions,
ComponentInternalInstance,
......@@ -142,17 +142,20 @@ export function handleEvent(
// 快手小程序的 __l 方法也会走此处逻辑,但没有 __ins__
if (__ins__) {
// 自定义事件,通过 triggerEvent 传递 __ins__
methodName = (__ins__.properties[EVENT_OPTS] || {})[type]
methodName = resolveMethodName(type, __ins__.properties[EVENT_OPTS] || {})
} else if (dataset && dataset[EVENT_OPTS]) {
// 快手小程序 input 等内置组件的 input 事件也会走此逻辑,所以从 dataset 中读取
methodName = dataset[EVENT_OPTS][type]
methodName = resolveMethodName(type, dataset[EVENT_OPTS])
}
if (!(this as any)[methodName]) {
return console.warn(type + ' not found')
}
;(this as any)[methodName](event)
}
function resolveMethodName(name: string, obj: Record<string, string>) {
return obj[name] || obj[hyphenate(name)]
}
/**
* @param properties
*/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册