ui.Button
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ปุ่มที่คลิกได้ซึ่งมีป้ายกำกับข้อความ
การใช้งาน | การคืนสินค้า |
---|
ui.Button(label, onClick, disabled, style, imageUrl) | ui.Button |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
label | สตริง ไม่บังคับ | ป้ายกำกับของปุ่ม ค่าเริ่มต้นคือสตริงว่างเปล่า |
onClick | ฟังก์ชัน (ไม่บังคับ) | Callback ที่เริ่มทำงานเมื่อมีการคลิกปุ่ม ระบบจะส่งวิดเจ็ตปุ่มไปยังฟังก์ชันเรียกกลับ |
disabled | บูลีน ไม่บังคับ | ปุ่มปิดใช้อยู่หรือไม่ ค่าเริ่มต้นคือ false |
style | ออบเจ็กต์ (ไม่บังคับ) | ออบเจ็กต์ของสไตล์ CSS ที่อนุญาตพร้อมค่าที่จะตั้งค่าสำหรับวิดเจ็ตนี้ ค่าเริ่มต้นจะเป็นออบเจ็กต์ที่ว่างเปล่า |
imageUrl | สตริง ไม่บังคับ | URL ของรูปภาพ (ไม่บังคับ) หากระบุไว้ ระบบจะแสดงปุ่มเป็นรูปภาพและแสดงข้อความค่าเมื่อวางเมาส์ อนุญาตเฉพาะข้อมูล: URL และไอคอนที่โหลดจาก gstatic.com |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eCreates a clickable button widget with customizable text label, click functionality, and appearance.\u003c/p\u003e\n"],["\u003cp\u003eAllows setting an optional image for the button, displaying the label text on hover.\u003c/p\u003e\n"],["\u003cp\u003eCan be disabled to prevent user interaction.\u003c/p\u003e\n"],["\u003cp\u003eProvides flexibility in styling through CSS properties.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes a straightforward constructor function for instantiation with various parameters.\u003c/p\u003e\n"]]],["The `ui.Button` function creates a clickable button. It accepts optional arguments: `label` (text), `onClick` (callback function on click), `disabled` (boolean to disable), `style` (CSS styling), and `imageUrl` (image for the button). When clicked, the `onClick` callback is triggered, receiving the button widget. The button can be customized with a text label or an image, and its appearance can be altered via CSS. Only specific URLs are allowed for the image.\n"],null,["# ui.Button\n\n\u003cbr /\u003e\n\nA clickable button with a text label.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------------------------------------------------------|-----------|\n| `ui.Button(`*label* `, `*onClick* `, `*disabled* `, `*style* `, `*imageUrl*`)` | ui.Button |\n\n| Argument | Type | Details |\n|------------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `label` | String, optional | The button's label. Defaults to an empty string. |\n| `onClick` | Function, optional | A callback fired when the button is clicked. The callback is passed the button widget. |\n| `disabled` | Boolean, optional | Whether the button is disabled. Defaults to false. |\n| `style` | Object, optional | An object of allowed CSS styles with their values to be set for this widget. Defaults to an empty object. |\n| `imageUrl` | String, optional | Optional image url. If provided, the button will be rendered as an image and the value text will be shown on mouse hover. Only data: urls and icons loaded from gstatic.com are allowed. |"]]