ui.Slider
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.
Một mục tiêu có thể kéo, có phạm vi tuyến tính giữa hai giá trị số. Giá trị của thanh trượt được hiển thị dưới dạng nhãn bên cạnh thanh trượt.
Cách sử dụng | Giá trị trả về |
---|
ui.Slider(min, max, value, step, onChange, direction, disabled, style) | ui.Slider |
Đối số | Loại | Thông tin chi tiết |
---|
min | Số, không bắt buộc | Giá trị tối thiểu. Giá trị mặc định là: 0 |
max | Số, không bắt buộc | Giá trị tối đa. Giá trị mặc định là 1. |
value | Số, không bắt buộc | Giá trị ban đầu. Giá trị mặc định là: 0 |
step | Số, không bắt buộc | Kích thước bước cho thanh trượt. Giá trị mặc định là 0,01. |
onChange | Hàm, không bắt buộc | Một lệnh gọi lại sẽ kích hoạt khi trạng thái của thanh trượt thay đổi. Lệnh gọi lại được truyền giá trị hiện tại của thanh trượt và tiện ích thanh trượt. |
direction | Chuỗi, không bắt buộc | Hướng của thanh trượt. Một trong các giá trị "horizontal" hoặc "vertical". Giá trị mặc định là "horizontal". |
disabled | Boolean, không bắt buộc | Thanh trượt có bị tắt hay không. Giá trị mặc định là false. |
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(). |
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\u003eThe \u003ccode\u003eui.Slider\u003c/code\u003e widget enables users to interactively select a numeric value within a defined range, visually represented by a draggable slider.\u003c/p\u003e\n"],["\u003cp\u003eIt offers customization options like minimum/maximum values, step size, initial value, orientation, and an onChange callback to respond to user interactions.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can further tailor its appearance using custom CSS styles through the \u003ccode\u003estyle\u003c/code\u003e argument.\u003c/p\u003e\n"]]],["The `ui.Slider` component creates a draggable slider between a minimum (`min`) and maximum (`max`) numeric value. It displays the current `value` with a label, adjustable by a defined `step`. The `direction` can be horizontal or vertical. An optional `onChange` function triggers on value changes, passing the current value. The slider can be `disabled`, and `style` properties are customizable. Default values are provided for `min`, `max`, `value`, and `step`.\n"],null,["# ui.Slider\n\n\u003cbr /\u003e\n\nA draggable target that ranges linearly between two numeric values. The value of the slider is displayed as a label alongside it.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------------------------------------------------------------------------------------------|-----------|\n| `ui.Slider(`*min* `, `*max* `, `*value* `, `*step* `, `*onChange* `, `*direction* `, `*disabled* `, `*style*`)` | ui.Slider |\n\n| Argument | Type | Details |\n|-------------|--------------------|------------------------------------------------------------------------------------------------------------------------------|\n| `min` | Number, optional | The minimum value. Defaults to 0. |\n| `max` | Number, optional | The maximum value. Defaults to 1. |\n| `value` | Number, optional | The initial value. Defaults to 0. |\n| `step` | Number, optional | The step size for the slider. Defaults to 0.01. |\n| `onChange` | Function, optional | A callback to fire when the slider's state changes. The callback is passed the slider's current value and the slider widget. |\n| `direction` | String, optional | The direction of the slider. One of 'horizontal' or 'vertical'. Defaults to 'horizontal'. |\n| `disabled` | Boolean, optional | Whether the slider is disabled. Defaults to false. |\n| `style` | Object, optional | An object of allowed CSS styles with their values to be set for this widget. See style() documentation. |"]]