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

{{APIRef("BroadCastChannel API")}}

+ +

BroadcastChannel.name 是类型为 {{domxref("DOMString")}} 的只读属性,是频道的唯一标识。属性 name 是在创建时传入 {{domxref("BroadcastChannel.BroadCastChannel", "BroadcastChannel()")}} 构造函数的,所以是只读的。

+ +

{{AvailableInWorkers}}

+ +

语法

+ +
var str = channel.name;
+
+ +

示例

+ +
// 连接到指定频道
+var bc = new BroadcastChannel('test_channel');
+
+// 其它操作 (如: postMessage, …)
+
+// 在控制台打印频道名称
+console.log(bc.name); // "test_channel"
+
+// 当完成后,断开与频道的连接
+bc.close();
+ +

规范

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

浏览器兼容性

+ + + +

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

+ +

参见

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