侧边栏允许节点和插件添加自定义标签页。
RED.sidebar API在侧边栏添加一个新标签页。
tab 定义是一个包含以下属性的对象:
| 属性 | 描述 |
|---|---|
id |
The unique id for this tab. |
label |
The text to display on the sidebar tab. This should not be too long. |
name |
The name of the tab displayed in the sidebar menu. |
iconClass |
The FontAwesome 4 class of the icon to use. For example, "fa fa-database" |
content |
The DOM element containing the content of the sidebar. |
toolbar |
(optional) A DOM element to display in the sidebar toolbar when this tab is active. |
enableOnEdit |
(optional) If set to true, this tab will be accessible whilst the edit dialog is open. Default: false. |
action |
(optional) The name of a registered action used to display this tab. This allows the user to assign a keyboard shortcut to switch to the tab. |
// The sidebar content
const content = $("<div>").css({"position":"relative","height":"100%"});
// (optional) A toolbar header for the sidebar
const header = $("<div>", {class:"red-ui-sidebar-header"}).appendTo(content);
RED.actions.add("my-custom-tab:show-custom-tab",function() {
RED.sidebar.show("my-custom-tab");
});
RED.sidebar.addTab({
id: "my-custom-tab",
label: "custom",
name: "My Custom Tab",
iconClass: "fa fa-database",
content: content,
action: "my-custom-tab:show-custom-tab"
});
如果该标签页存在,则将其移除。
如果一个节点在其onpaletteadd函数中添加了一个标签页,它必须确保在onpaletteremove函数中调用此API来移除它。
RED.sidebar.removeTab("my-custom-tab");
如果存在,在侧边栏中显示给定的标签页。
RED.sidebar.show("my-custom-tab")
如果侧边栏中存在该标签页,则返回 true
let debugExists = RED.sidebar.containsTab('my-custom-tab');
Node-RED: 面向事件驱动应用的低代码编程平台。
版权所有 OpenJS基金会 及 Node-RED 贡献者。保留所有权利。OpenJS基金会 拥有注册商标并使用商标。有关 OpenJS基金会 的商标列表,请参阅我们的 商标政策 和 商标列表。未在 OpenJS基金会商标列表 中标注的商标™或注册®商标归其各自持有人所有。使用这些商标并不意味着与它们有任何关联或获得其认可。
The OpenJS Foundation | 使用条款 | 隐私政策 | OpenJS基金会章程 | 商标政策 | 商标列表 | Cookie政策