contextualIdentities.onUpdated
当场景身份的属性(例如其名称、图标或颜色)发生变化时触发。场景身份可以由扩展使用 contextualIdentities
API 更新,也可以由用户直接通过浏览器的用户界面更新。
语法
js
browser.contextualIdentities.onUpdated.addListener(listener)
browser.contextualIdentities.onUpdated.removeListener(listener)
browser.contextualIdentities.onUpdated.hasListener(listener)
事件有三个函数:
addListener(listener)
-
向此事件添加一个监听器。
removeListener(listener)
-
停止监听此事件。
listener
参数是要移除的监听器。 hasListener(listener)
-
检查
listener
是否已注册此事件。如果正在监听,返回true
,否则返回false
。
addListener 语法
参数
listener
-
当此事件发生时调用的函数。该函数传递一个参数:
changeInfo
-
object
。包含单个属性contextualIdentity
的对象(一个contextualIdentities.ContextualIdentity
对象表示属性被更新的身份)。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
onUpdated |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
示例
js
function handleUpdated(changeInfo) {
console.log(`已更新:${changeInfo.contextualIdentity.name}`);
}
browser.contextualIdentities.onUpdated.addListener(handleUpdated);