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

fix(v3): event handler #1279

上级 e6c0126a
......@@ -94,7 +94,9 @@ export function processEvent (name, $event = {}, detail = {}, target = {}, curre
const nid = currentTarget.getAttribute('_i')
ret.options = {
nid
}
}
// 保留原始 currentTarget 方便后续对比
ret.$origCurrentTarget = currentTarget
}
return ret
......
......@@ -29,9 +29,10 @@ export function initEvent (Vue) {
}
const $event = this.$handleEvent($vueEvent)
const cid = this._$id
// 当自定义组件根节点触发事件时,nid 始终为 0
const nid = $vueEvent.currentTarget === this.$el ? 0 : $event.options.nid
const cid = this._$id
// 当自定义组件根节点触发事件时,nid 始终为 0
const currentTarget = $vueEvent.$origCurrentTarget || $vueEvent.currentTarget
const nid = currentTarget === this.$el ? 0 : $event.options.nid
if (typeof nid === 'undefined') {
return console.error(`[${cid}] nid not found`)
}
......@@ -41,7 +42,8 @@ export function initEvent (Vue) {
delete $event.mp
delete $event.preventDefault
delete $event.stopPropagation
delete $event.options
delete $event.options
delete $event.$origCurrentTarget
// 实时发送,延迟的话,会导致 touch 类事件被合并,影响实际业务逻辑,比如 touchstart 中修改变量为 true,touchend 修改为 false
vd.sendUIEvent(cid, nid, $event)
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册