在vue3 中 利用postMessage进行不同的项目传递消息
// 接收消息
window.addEventListener('message', (e) => {
console.log(e.data) // 拿到的参数
})
// 发送消息
const targetWindow = window.open('http://你选择要跳转的项目连接');
setTimeout(()=>{
targetWindow.postMessage('传递过去的参数', 'http://你自己连接')
}, 3000)
场景:可以在不同的项目中进行一些跳转时,传递一些参数
注意:发送消息的时候要写好跳转的链接