From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/broadcastchannel/close/index.html | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 files/zh-cn/web/api/broadcastchannel/close/index.html (limited to 'files/zh-cn/web/api/broadcastchannel/close/index.html') diff --git a/files/zh-cn/web/api/broadcastchannel/close/index.html b/files/zh-cn/web/api/broadcastchannel/close/index.html new file mode 100644 index 0000000000..e3eb201840 --- /dev/null +++ b/files/zh-cn/web/api/broadcastchannel/close/index.html @@ -0,0 +1,55 @@ +--- +title: BroadcastChannel.close() +slug: Web/API/BroadcastChannel/close +translation_of: Web/API/BroadcastChannel/close +--- +

{{APIRef("BroadCastChannel API")}}

+ +

通过调用 BroadcastChannel.close() 方法,可以马上断开其与对应频道的关联,并让其被垃圾回收。这是必要的步骤,因为浏览器没有其它方式知道频道不再被需要。

+ +

{{AvailableInWorkers}}

+ +

语法

+ +
var str = channel.close();
+
+ +

示例

+ +
// 连接到指定频道
+var bc = new BroadcastChannel('test_channel');
+
+// 其它操作 (如: postMessage, …)
+
+// 当完成后,断开与频道的连接
+bc.close();
+
+ +

规范

+ + + + + + + + + + + + + + +
规范状态备注
{{SpecName('HTML WHATWG', "comms.html#dom-broadcastchannel-close", "BroadcastChannel.close()")}}{{Spec2('HTML WHATWG')}}Initial definition.
+ +

浏览器兼容性

+ + + +

{{Compat("api.BroadcastChannel.close")}}

+ +

另见

+ + -- cgit v1.2.3-54-g00ecf