1、新窗口
window.opener.postMessage('save', '*');
2、vue项目的老窗口
onBeforeMount(() => {
webtopoFormUrl.value = `${webtopoUrl}#/Preview?processId=${props.processId}&token=${cookie.get(tokenKey)}`;
window.addEventListener('message', (event) => {
console.log('监听事件');
console.log(event.data);
if (event.data == 'save') {
//业务逻辑
}
});
});
onUnmounted(() => {
//组件销毁
window.removeEventListener('message');
});