You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
432 B
15 lines
432 B
function initMessage() {
|
|
window.parent.postMessage('created', '*');
|
|
window.addEventListener('message', function (event) {
|
|
try {
|
|
const data = JSON.parse(event.data);
|
|
// 消息格式: {type: 'data', data: { ... }}
|
|
if (data.type === 'data') {
|
|
console.log('game message: -->', data.data);
|
|
window.parentData = data.data;
|
|
}
|
|
} catch (error) {
|
|
// console.error(error);
|
|
}
|
|
})
|
|
}
|
|
|