communication-channel

1.0.1 • Public • Published

简介

communication-channel 是一个用于浏览器端跨页面通信的库。

使用

安装

  • NPM 引入

    npm install communication-channel

示例

import { CommunicationChannel } from 'communication-channel'
const channel = new CommunicationChannel('test')
// 发送信息
channel.postMessage('test message')
// 监听信息方式一
channel.onmessage = msg => console.dir(msg)
// 监听信息方式二
channel.addEventListener('message', handler)
// remove 监听
channel.removeEventListener('message', handler)
// 关闭通信
channel.close()

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i communication-channel

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

11.3 kB

Total Files

8

Last publish

Collaborators

  • yaoshuangun