Skip to content

Commit

Permalink
fix(mp): 修复uni上不存在的属性也会获取到一个方法的Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangyaqi committed Jan 15, 2025
1 parent be854a6 commit 9fc6adb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/uni-mp-core/src/api/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ export function initWrapper(protocols: MPProtocols) {
* 注意:
* - 此处method为原始全局对象上的uni方法名对应的属性值,比如method值可能为my.login,即undefined
* - uni.env并非方法,但是也会被传入wrapper
* - 开发者自定义的方法属性也会进入此方法,此时method为undefined,应返回undefined
*/

const hasProtocol = hasOwn(protocols, methodName)
if (!hasProtocol && typeof __GLOBAL__[methodName] !== 'function') {
return method
}
const needWrapper =
hasProtocol ||
isFunction(protocols.returnValue) ||
Expand Down

0 comments on commit 9fc6adb

Please sign in to comment.