需求
需要在当前页面使用微信等第三方授权,在授权完成后,关闭授权窗口后,系统当前页面响应。

相关Api
相关代码demo
Vue
<script>let win;export default {...mounted() {if (window.opener) {window.opener.postMessage(data, window.location.hostname);}window.addEventListener('message',e => {if (e.data) {setTimeout(() => {win.close(); 关闭新窗口win = null; // 关闭窗口后,释放内存}, 1000);// todo}},false,);},methods: {onOpen() {win = window.open(data, '_blank', 'top=200px,width=800px,height=600px');}}}</script>
