@fle-tools/pm
v2.0.7
Published
@fle-tools/pm
Downloads
3
Readme
@fle-tools/pm
Based Post Message
Installation
Install via your package manager
npm i @fle-tools/pm
# or
yarn add @fle-tools/pm
Usage
// 父应用
import PM = from '@fle-tools/pm';
const Message = new Message({
targetOrigin: '*',
isLogger: true,
})
Message.emit({
type: 'ADD_TODO',
payload: {
test: 'test'
}
});
Message.on('ADD_TODO', (payload) => {
console.log(payload);
});
Message.destroy();
子应用
API
| 参数名 | 必填 | 类型 | 默认值 | 备注 | | ------ | ---- | ---- | ------ | ---- | | iframeId | false | string | fle_pm__Iframe | iframeId | | identity | true | 'parent'|'child' | 'parent' | 当前所处身份 是父应用 还是子应用 | | host | true | string | '‘ | 应用host。 |
Action
| 事件名 | 必填 | 类型 | 备注 | | ------ | ---- | ---- | ------ | | on | false | function | 监听message | | emit | false | function | 发送message | | destroy | false | function | 销毁message监听 |