ui.Label
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Nhãn văn bản.
Cách sử dụng | Giá trị trả về |
---|
ui.Label(value, style, targetUrl, imageUrl) | ui.Label |
Đối số | Loại | Thông tin chi tiết |
---|
value | Chuỗi, không bắt buộc | Văn bản cần hiển thị. Giá trị mặc định là một chuỗi trống. |
style | Đối tượng, không bắt buộc | Một đối tượng gồm các kiểu CSS được phép có giá trị sẽ được đặt cho tiện ích này. Xem tài liệu style(). |
targetUrl | Chuỗi, không bắt buộc | URL để liên kết. Giá trị mặc định là một chuỗi trống. |
imageUrl | Chuỗi, không bắt buộc | URL hình ảnh không bắt buộc. Nếu được cung cấp, nhãn sẽ được hiển thị dưới dạng hình ảnh và văn bản giá trị sẽ xuất hiện khi di chuột. Chỉ cho phép sử dụng các URL dữ liệu và biểu tượng được tải từ gstatic.com. |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003eCreates a text label UI element that can optionally display an image and link to a URL.\u003c/p\u003e\n"],["\u003cp\u003eCustomization options include text value, CSS styling, target URL, and image URL.\u003c/p\u003e\n"],["\u003cp\u003eImage URLs are restricted to data URLs and icons from gstatic.com, displayed on hover with the text value as a tooltip.\u003c/p\u003e\n"],["\u003cp\u003eDefault values are provided for optional arguments, resulting in an empty label with no styling or linking.\u003c/p\u003e\n"]]],["The `ui.Label` function creates a text label with optional styling, a target URL, and an image. The `value` argument sets the displayed text, `style` customizes the CSS, `targetUrl` defines a link, and `imageUrl` displays an image with hover text. The text, style, URL, and image arguments are all optional and have default values. The label will only allow images from gstatic.com or data urls.\n"],null,["# ui.Label\n\n\u003cbr /\u003e\n\nA text label.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|------------------------------------------------------------------|----------|\n| `ui.Label(`*value* `, `*style* `, `*targetUrl* `, `*imageUrl*`)` | ui.Label |\n\n| Argument | Type | Details |\n|-------------|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `value` | String, optional | The text to display. Defaults to an empty string. |\n| `style` | Object, optional | An object of allowed CSS styles with their values to be set for this widget. See style() documentation. |\n| `targetUrl` | String, optional | The url to link to. Defaults to an empty string. |\n| `imageUrl` | String, optional | Optional image url. If provided, the label 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. |"]]