读取主文件信息方法 - runtime.getManifest()
该方法会获取一个完整的主文件 manifest.json,并返回一个序列化后的 JSON 对象。
语法
js
browser.runtime.getManifest();
参数
无。
返回值
是一个能表示主文件所有信息的 JSON 对象。
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getManifest |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full 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.
示例
取得主文件中的 name 特性的值,并输出到控制台:
js
var manifest = browser.runtime.getManifest();
console.log(manifest.name);
示例扩展
备注:
This API is based on Chromium's chrome.runtime
API. This documentation is derived from runtime.json
in the Chromium code.