Skip to content

Commit a0b341b

Browse files
authored
Merge pull request #2326 from didi/fix-onload-params-codetype
拉齐各端onload的返回结果
2 parents b3cf692 + 5f11d01 commit a0b341b

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

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

Lines changed: 13 additions & 1 deletion
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') {
@@ -13,7 +14,18 @@ export default function pageStatusMixin (mixinType) {
1314
this.__mpxProxy.callHook(ONRESIZE, [e])
1415
},
1516
onLoad (query) {
16-
this.__mpxProxy.callHook(ONLOAD, [query])
17+
if (__mpx_mode__ === 'wx') {
18+
const loadParams = {}
19+
// 此处单独处理微信与其他端保持一致,传入onload的参数都是经过decodeURIComponent处理过的
20+
if (isObject(query)) {
21+
for (const key in query) {
22+
loadParams[key] = decodeURIComponent(query[key])
23+
}
24+
}
25+
this.__mpxProxy.callHook(ONLOAD, [loadParams])
26+
} else {
27+
this.__mpxProxy.callHook(ONLOAD, [query])
28+
}
1729
}
1830
}
1931
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)