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

feat(uni-h5-ui): add $handleEvent

上级 da44c7f3
......@@ -7,6 +7,10 @@ import 'uni-core/view/index.css'
import uni from './ui-api.js'
import {
processEvent
} from 'uni-core/view/plugins/events'
const oldIsReservedTag = Vue.config.isReservedTag
global.uni = uni
......@@ -28,4 +32,23 @@ Vue.config.getTagNamespace = function (tag) {
return oldGetTagNamespace(tag) || false
}
const findUniTarget = function ($event, $el) {
let target = $event.target
for (; target && target !== $el; target = target.parentNode) {
if (target.tagName && target.tagName.indexOf('UNI-') === 0) {
break
}
}
return target
}
Vue.prototype.$handleEvent = function ($event) {
if ($event instanceof Event) { // 未处理的 event 对象 需要对 target 校正及包装
// 查找 uniTarget
const target = findUniTarget($event, this.$el)
$event = processEvent.call(this, $event.type, $event, {}, target || $event.target, $event.currentTarget)
}
return $event
}
require('uni-components')
......@@ -7,7 +7,7 @@
"lint:cli": "eslint --fix --config package.json --ignore-path .eslintignore packages/uni-cli-shared packages/uni-template-compiler \"packages/vue-cli-*/**/*.js\" \"packages/webpack-uni-*/**/*.js\"",
"dev:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=true UNI_PLATFORM=h5 node build/build.js",
"build:h5": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 node build/build.js",
"build:h5:ui": "npm run lint && cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 UNI_UI=true node build/build.js",
"build:h5:ui": "cross-env NODE_ENV=production UNI_WATCH=false UNI_PLATFORM=h5 UNI_UI=true node build/build.js",
"build:app-plus": "cross-env UNI_PLATFORM=app-plus rollup -c build/rollup.config.mp.js",
"build:app:all": "npm run lint && npm run build:app:nvue && npm run build:app:legacy",
"build:app:nvue": "cross-env UNI_PLATFORM=app-plus-nvue rollup -c build/rollup.config.app.js",
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册