forked from dcloudio/uni-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 兜底data-event-list 属性为 undefined 的情况
- Loading branch information
1 parent
36c9f21
commit 1d55302
Showing
2 changed files
with
54 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
}) | ||
} |