Displays a JSON object in the extension's sidebar pane.
The object is displayed as an expandable tree, as in the
JSON viewer
in Firefox. You can optionally specify a
rootTitle
string: this will be displayed as the title of the tree's root.
This is an asynchronous function that returns a
Promise
.
var setting = browser.devtools.panels.setObject(
jsonObject
,
// string, array, or JSON object
rootTitle
// string
)
jsonObject
字符串
or
数组
or
对象
. The object to display. If this is an object it is JSON-serialized, so properties like functions will be omitted.
rootTitle
可选
字符串
. The title of the root of the tree in which the object is displayed.
A
Promise
that will be fulfilled with no arguments, once the object has been set.
BCD tables only load in the browser
Create a new pane, and populate it with a JSON object. You could run this code in a script loaded by your extension's devtools page .
function onCreated(sidebarPane) {
sidebarPane.setObject({
someBool: true,
someString: "hello there",
someObject: {
someNumber: 42,
someOtherString: "this is my pane's content"
}
});
}
browser.devtools.panels.elements.createSidebarPane("My pane").then(onCreated);
注意:
This API is based on Chromium's
chrome.devtools.panels
API。
最后修改: , 由 MDN 贡献者