Nietzsche's Preposterous Moustache

    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()

    Install

    npm i communication-channel

    DownloadsWeekly Downloads

    1

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    11.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • yaoshuangun