Datetime Component: Additional Display Methods with Event and Method Demonstration Examples
Category: ExamplesThe datetime component can create date picker instances, supporting single or multiple date selection, date range selection, lunar calendar usage, and custom events.
Multi-line Display
Set the mode="multiple"
attribute to enable multiple date selection. When multiple selections would overflow a single line, use the multiline attribute to display dates across multiple lines.
Date Range Selection
Enable date range selection by setting the mode="range"
attribute.
Using Tools
The text field toolbox can be set via the tools
attribute. Simply adding the tools attribute or setting tools=true will enable the default clear button.
Event Listeners
Since the component contains a non-hidden text field, it has all text field events (input, change, paste, select (highlight selection), etc.).
Since passing parameters with addEventListener
is cumbersome, an additional set of listener events is provided.
Operation Methods
Built-in common methods include reset()
, clear()
, and set(data)
, along with input-specific blur
and focus
methods. Based on these methods, the component provides corresponding listener events.
Using Validation
Form field validation is an independent operation method.
Using Cache
When modifying element properties or values, if you need to cache data to restore previous properties and values when reloading the page, use the stor-name
attribute. However, ensure this attribute value is unique in the browser cache.