From 1d55302024c272d8f9c59918f166e753e6ac507b Mon Sep 17 00:00:00 2001 From: EAGzzyCSL Date: Sat, 8 Oct 2022 16:36:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=85=9C=E5=BA=95data-event-list=20?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E4=B8=BA=20undefined=20=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mp-alipay/runtime/wrapper/util.js | 4 +- src/platforms/mp-xhs/runtime/wrapper/util.js | 104 +++++++++--------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/platforms/mp-alipay/runtime/wrapper/util.js b/src/platforms/mp-alipay/runtime/wrapper/util.js index 59bde8c70..508e949e0 100644 --- a/src/platforms/mp-alipay/runtime/wrapper/util.js +++ b/src/platforms/mp-alipay/runtime/wrapper/util.js @@ -111,7 +111,7 @@ export function initChildVues (mpInstance) { function handleProps (ref) { const eventProps = {} let refProps = ref.props - const eventList = refProps['data-event-list'].split(',') + const eventList = (refProps['data-event-list'] || '').split(',') // 初始化支付宝小程序组件事件 Object.keys(refProps).forEach(key => { if (eventList.includes(key)) { @@ -227,7 +227,7 @@ export const handleLink = (function () { export const handleWrap = function (mp, destory) { const vueId = mp.props.vueId - const list = mp.props['data-event-list'].split(',') + const list = (mp.props['data-event-list'] || '').split(',') list.forEach(eventName => { const key = `${eventName}${vueId}` if (destory) { diff --git a/src/platforms/mp-xhs/runtime/wrapper/util.js b/src/platforms/mp-xhs/runtime/wrapper/util.js index b9eb54824..5565a5fe0 100644 --- a/src/platforms/mp-xhs/runtime/wrapper/util.js +++ b/src/platforms/mp-xhs/runtime/wrapper/util.js @@ -1,52 +1,52 @@ -import { - isFn, - hasOwn -} from 'uni-shared' - -export const isComponent2 = xhs.canIUse('component2') - -export const mocks = ['$id'] - -export function initSpecialMethods (mpInstance) { - if (!mpInstance.$vm) { - return - } - let path = mpInstance.is || mpInstance.route - if (!path) { - return - } - if (path.indexOf('/') === 0) { - path = path.substr(1) - } - const specialMethods = xhs.specialMethods && xhs.specialMethods[path] - if (specialMethods) { - specialMethods.forEach(method => { - if (isFn(mpInstance.$vm[method])) { - mpInstance[method] = function (event) { - if (hasOwn(event, 'markerId')) { - event.detail = typeof event.detail === 'object' ? event.detail : {} - event.detail.markerId = event.markerId - } - // TODO normalizeEvent - mpInstance.$vm[method](event) - } - } - }) - } -} - -export const handleWrap = function (mp, destory) { - const vueId = mp.props.vueId - const list = mp.props['data-event-list'].split(',') - list.forEach(eventName => { - const key = `${eventName}${vueId}` - if (destory) { - delete this[key] - } else { - // TODO remove handleRef - this[key] = function () { - mp.props[eventName].apply(this, arguments) - } - } - }) -} +import { + isFn, + hasOwn +} from 'uni-shared' + +export const isComponent2 = xhs.canIUse('component2') + +export const mocks = ['$id'] + +export function initSpecialMethods (mpInstance) { + if (!mpInstance.$vm) { + return + } + let path = mpInstance.is || mpInstance.route + if (!path) { + return + } + if (path.indexOf('/') === 0) { + path = path.substr(1) + } + const specialMethods = xhs.specialMethods && xhs.specialMethods[path] + if (specialMethods) { + specialMethods.forEach(method => { + if (isFn(mpInstance.$vm[method])) { + mpInstance[method] = function (event) { + if (hasOwn(event, 'markerId')) { + event.detail = typeof event.detail === 'object' ? event.detail : {} + event.detail.markerId = event.markerId + } + // TODO normalizeEvent + mpInstance.$vm[method](event) + } + } + }) + } +} + +export const handleWrap = function (mp, destory) { + const vueId = mp.props.vueId + const list = (mp.props['data-event-list'] || '').split(',') + list.forEach(eventName => { + const key = `${eventName}${vueId}` + if (destory) { + delete this[key] + } else { + // TODO remove handleRef + this[key] = function () { + mp.props[eventName].apply(this, arguments) + } + } + }) +} -- GitLab