提交 1e2476c7 编写于 作者: eagzzycsl's avatar eagzzycsl 提交者: qiang

fix: 兜底data-event-list 属性为 undefined 的情况

上级 041435a0
...@@ -111,7 +111,7 @@ export function initChildVues (mpInstance) { ...@@ -111,7 +111,7 @@ export function initChildVues (mpInstance) {
function handleProps (ref) { function handleProps (ref) {
const eventProps = {} const eventProps = {}
let refProps = ref.props let refProps = ref.props
const eventList = refProps['data-event-list'].split(',') const eventList = (refProps['data-event-list'] || '').split(',')
// 初始化支付宝小程序组件事件 // 初始化支付宝小程序组件事件
Object.keys(refProps).forEach(key => { Object.keys(refProps).forEach(key => {
if (eventList.includes(key)) { if (eventList.includes(key)) {
...@@ -227,7 +227,7 @@ export const handleLink = (function () { ...@@ -227,7 +227,7 @@ export const handleLink = (function () {
export const handleWrap = function (mp, destory) { export const handleWrap = function (mp, destory) {
const vueId = mp.props.vueId const vueId = mp.props.vueId
const list = mp.props['data-event-list'].split(',') const list = (mp.props['data-event-list'] || '').split(',')
list.forEach(eventName => { list.forEach(eventName => {
const key = `${eventName}${vueId}` const key = `${eventName}${vueId}`
if (destory) { if (destory) {
......
import { import {
isFn, isFn,
hasOwn hasOwn
} from 'uni-shared' } from 'uni-shared'
export const isComponent2 = xhs.canIUse('component2') export const isComponent2 = xhs.canIUse('component2')
export const mocks = ['$id'] export const mocks = ['$id']
export function initSpecialMethods (mpInstance) { export function initSpecialMethods (mpInstance) {
if (!mpInstance.$vm) { if (!mpInstance.$vm) {
return return
} }
let path = mpInstance.is || mpInstance.route let path = mpInstance.is || mpInstance.route
if (!path) { if (!path) {
return return
} }
if (path.indexOf('/') === 0) { if (path.indexOf('/') === 0) {
path = path.substr(1) path = path.substr(1)
} }
const specialMethods = xhs.specialMethods && xhs.specialMethods[path] const specialMethods = xhs.specialMethods && xhs.specialMethods[path]
if (specialMethods) { if (specialMethods) {
specialMethods.forEach(method => { specialMethods.forEach(method => {
if (isFn(mpInstance.$vm[method])) { if (isFn(mpInstance.$vm[method])) {
mpInstance[method] = function (event) { mpInstance[method] = function (event) {
if (hasOwn(event, 'markerId')) { if (hasOwn(event, 'markerId')) {
event.detail = typeof event.detail === 'object' ? event.detail : {} event.detail = typeof event.detail === 'object' ? event.detail : {}
event.detail.markerId = event.markerId event.detail.markerId = event.markerId
} }
// TODO normalizeEvent // TODO normalizeEvent
mpInstance.$vm[method](event) mpInstance.$vm[method](event)
} }
} }
}) })
} }
} }
export const handleWrap = function (mp, destory) { export const handleWrap = function (mp, destory) {
const vueId = mp.props.vueId const vueId = mp.props.vueId
const list = mp.props['data-event-list'].split(',') const list = (mp.props['data-event-list'] || '').split(',')
list.forEach(eventName => { list.forEach(eventName => {
const key = `${eventName}${vueId}` const key = `${eventName}${vueId}`
if (destory) { if (destory) {
delete this[key] delete this[key]
} else { } else {
// TODO remove handleRef // TODO remove handleRef
this[key] = function () { this[key] = function () {
mp.props[eventName].apply(this, arguments) mp.props[eventName].apply(this, arguments)
} }
} }
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册