1.分享的页面 onShareAppMessage
,使用 encodeURIComponent
包裹 JSON.stringify
字段
onShareAppMessage: function (res) {
let _options ={
a: 'xxxxx',
b: 'xxxxxxx'
}
const json = encodeURIComponent(JSON.stringify(_options))
const _share = {
title:'健康中国 我们行动',
path:'pages/online-phase-test/online-phase-test?options='+json,
imageUrl: '',
};
return _share
},
2. online-phase-test
页面接收 需要在 onLoad
这个声明周期使用,decodeURIComponent
用这个进行解析
onLoad: function (options) {
if (options) {
const _options = JSON.parse(decodeURIComponent(options.options))
console.log('_options---------------',_options)
this.setData({
options:_options
})
}
},