【问题标题】:Uncaught ReferenceError: BroadcastChannel is not defined未捕获的 ReferenceError:未定义 BroadcastChannel
【发布时间】:2022-01-26 02:48:30
【问题描述】:

尝试为支持 broadcast channel 的 deno 部署应用程序在本地运行 deno,但出现此编译错误我该如何解决?

const channel = new BroadcastChannel('')
Uncaught ReferenceError: BroadcastChannel is not defined

【问题讨论】:

  • 您使用的是什么deno 版本? deno 1.14.1v> 版本支持广播频道
  • 1.17 我很确定我只需要设置 --unstable

标签: deno


【解决方案1】:

它在 v1.17.1 的稳定文档中,所以不需要 --unstable 来使用它:

https://doc.deno.land/deno/stable@v1.17.1/~/BroadcastChannel

与不稳定的比较:https://doc.deno.land/deno/unstable@v1.17.1

然而,事实并非如此:

$ deno
Deno 1.17.1
exit using ctrl+d or close()
> new BroadcastChannel()
Uncaught ReferenceError: BroadcastChannel is not defined
    at <anonymous>:2:1
> close()
$ deno --unstable
Deno 1.17.1
exit using ctrl+d or close()
> new BroadcastChannel()
Uncaught TypeError: Failed to construct 'BroadcastChannel': 1 argument required, but only 0 present.
    at Object.requiredArguments (deno:ext/webidl/00_webidl.js:627:13)
    at new BroadcastChannel (deno:ext/broadcast_channel/01_broadcast_channel.js:81:14)
    at <anonymous>:2:1
> close()

您可以在the repo 中提出问题。

编辑:已创建问题:denoland/deno#13214

【讨论】:

    猜你喜欢
    • 2023-01-23
    • 2016-11-03
    • 2011-01-05
    • 2016-01-02
    • 2013-10-06
    • 2016-12-17
    • 1970-01-01
    相关资源
    最近更新 更多