feat(h5): 引入微信JSSDK并实现跨域消息通信
- 在H5环境中动态加载微信JSSDK 实脚本 -现向父窗口发送postMessage消息 - 支持向微信小程序发送postMessage消息 - 添加延迟执行机制确保消息发送时机 - 增强与微信小程序的交互能力
This commit is contained in:
@@ -113,6 +113,27 @@
|
||||
|
||||
onLoad((options) => {
|
||||
console.log('🚀 ~ 🐶106 ~ options: ', options);
|
||||
setTimeout(() => {
|
||||
window?.parent?.postMessage(
|
||||
{
|
||||
data: {
|
||||
code: 'success',
|
||||
test: '我是子页面的test!',
|
||||
},
|
||||
},
|
||||
'*',
|
||||
);
|
||||
wx?.miniProgram?.postMessage({
|
||||
data: {
|
||||
action: 'type',
|
||||
message: '1234',
|
||||
timestamp: new Date().getTime(),
|
||||
},
|
||||
});
|
||||
console.log(wx?.miniProgram?.postMessage);
|
||||
console.log(window?.parent);
|
||||
}, 2000);
|
||||
|
||||
if (options?.fileUrl) {
|
||||
isEdit.value = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user