spz-variants
When to Use
When you need to display product variants and make a selection, typically used on product detail pages, quick add-to-cart popups, etc.
Code Demonstration
Basic Usage
- Only supports
fieldsetandselectelements as single variant blocks, they need to have anameattribute, with the value being the name of the variant, indicating which variant block it is. - Variant blocks internally use native form controls to implement variant selection.
- Each variant option element needs to have an
optionattribute, its value matching thevalueattribute, representing the current variant option value.
Attributes
src Data Source Methods
There are two ways to obtain data:
- Get data via the API
script:<scriptId>: Get data through ascript
Methods
variantsRender
Render variants.
Events
event Object Data
mouseout
This event is automatically triggered when the mouse leaves a variant option.
[variantName]mouseover
When the mouse enters an option of the corresponding variant name, the mouseover event for that variant name is automatically triggered. For example: If there is a color variant, when the mouse enters its variant option, the colormouseover event is triggered.
AI Summary (LLM Ready)
- Component ID:
spz-variants - One-line purpose: Display the product variant blocks.
- Detected attribute rows: 9
- Detected method subsections: 1
- Detected event subsections: 3
- Top attribute names:
src,manual,inherit-url-variant,disabled-default-value,switch-slide,slide - Top method names:
variantsRender - Top event names:
mouseout,[variantName]mouseover - Reading order: start from usage/examples, then verify attributes, methods, and events.
- Related docs: /en/guide/actions-and-events/ , /en/guide/layouts/