Skip to content

Commit 9d23d85

Browse files
author
wangcuijuan
committed
去掉RN下的encode处理,在wx中onload的参数进行decode的处理,与其他平台保持结果一致
1 parent c4736a3 commit 9d23d85

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

packages/core/src/platform/builtInMixins/pageStatusMixin.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { CREATED, ONLOAD, ONSHOW, ONHIDE, ONRESIZE } from '../../core/innerLifecycle'
2+
import { isObject } from '@mpxjs/utils'
23

34
export default function pageStatusMixin (mixinType) {
45
if (mixinType === 'page') {
@@ -49,6 +50,18 @@ export default function pageStatusMixin (mixinType) {
4950
})
5051
delete pageMixin.onResize
5152
}
53+
if (__mpx_mode__ === 'wx') {
54+
pageMixin.onLoad = function (query) {
55+
const loadParams = {}
56+
// 此处单独处理微信与其他端保持一致,传入onload的参数都是经过decodeURIComponent处理过的
57+
if (isObject(query)) {
58+
for (const key in query) {
59+
loadParams[key] = decodeURIComponent(query[key])
60+
}
61+
}
62+
this.__mpxProxy.callHook(ONLOAD, [loadParams])
63+
}
64+
}
5265
return pageMixin
5366
} else {
5467
if (__mpx_mode__ === 'ali') {

packages/core/src/platform/patch/getDefaultOptions.ios.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,7 @@ function createInstance ({ propsRef, type, rawOptions, currentInject, validProps
314314

315315
if (type === 'page') {
316316
const props = propsRef.current
317-
const loadParams = {}
318-
// 此处拿到的props.route.params内属性的value被进行过了一次decode, 不符合预期,此处额外进行一次encode来与微信对齐
319-
if (isObject(props.route.params)) {
320-
for (const key in props.route.params) {
321-
loadParams[key] = encodeURIComponent(props.route.params[key])
322-
}
323-
}
324-
proxy.callHook(ONLOAD, [loadParams])
317+
proxy.callHook(ONLOAD, [props.route.params || {}])
325318
}
326319

327320
Object.assign(proxy, {

0 commit comments

Comments
 (0)