iframe-ipcs
v1.1.3
Published
iframe-ipcs
Downloads
6
Readme
iframe-ipcs
跨iframe通讯,对齐promise调用体验。加密传递数据
Install
npm install iframe-ipcs --save
Usage
支持promise编程
import { IframeIPCs } from 'iframe-ipcs';
const iframeIpc = new IframeIPCs('namespace', { aes: 'abcdefg' });
const serverApi = iframeIpc.defServerAPI('api123', async (args: number): Promise<string> => {
return '' + args;
});
// top 外层 ifreame
iframeIpc.initFrameServer();
// client 内层 iframe
serverApi(1234).then((result) => console.log(result));