ui.root.add
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เพิ่มวิดเจ็ตลงในแผงรูท
แสดงผลแผงรูท
การใช้งาน | การคืนสินค้า |
---|
ui.root.add(widget) | ui.Panel |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
widget | ui.Widget | วิดเจ็ตที่จะเพิ่ม |
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (JavaScript)
// Replace the default UI widgets with a few custom widgets.
ui.root.clear();
ui.root.add(
ui.Panel({
widgets:[
ui.Label('This is a custom user interface.'),
],
style: {border: '5px solid green'}
})
);
ui.root.add(ui.Map());
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eThe \u003ccode\u003eui.root\u003c/code\u003e object allows you to add and manage widgets within the main user interface panel.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eadd()\u003c/code\u003e method specifically inserts a specified widget into the root panel, modifying the display.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eclear()\u003c/code\u003e method can be used to remove existing widgets, providing flexibility in UI customization.\u003c/p\u003e\n"]]],[],null,["# ui.root.add\n\n\u003cbr /\u003e\n\nAdds a widget to the root panel.\n\n\u003cbr /\u003e\n\nReturns the root panel.\n\n| Usage | Returns |\n|-----------------------|----------|\n| `ui.root.add(widget)` | ui.Panel |\n\n| Argument | Type | Details |\n|----------|-----------|-------------------------|\n| `widget` | ui.Widget | The widget to be added. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Replace the default UI widgets with a few custom widgets.\nui.root.clear();\nui.root.add(\n ui.Panel({\n widgets:[\n ui.Label('This is a custom user interface.'),\n ],\n style: {border: '5px solid green'}\n })\n);\nui.root.add(ui.Map());\n```"]]