spz-quantity
Display a quantity switcher.
Layouts
跳转到“Layouts”Usage
跳转到“Usage”<spz-quantity
layout="fixed-height"
height="40"
name="quantity"
min="1"
max="8"
value="1"
icon-class="quantity-buttons"
number-class="quantity-input"
></spz-quantity>
Attributes
跳转到“Attributes”value
跳转到“value”An integer number is a current value. Its default value is 1
.
max
跳转到“max”The maximum value the value
can increase to. Its default is Number.MAX_VALUE
.
min
跳转到“min”The minimum value the value
can decrease to. Its default is Number.MIN_VALUE
.
icon-class
跳转到“icon-class”A class added to the plus
and minus
buttons.
number-class
跳转到“number-class”A class added to the input
element.
variant-id
跳转到“variant-id”You can specify a corresponding the spz-variants
id, and update the max
, min
and value
of the spz-quantity
through the variantChange
event.
Actions
跳转到“Actions”update
跳转到“update”update(isTriggerChange=<Boolean>[, value=<Number>, min=<Number>, max=<Number>])
Specify an object to update the value
, min
, max
, and isTriggerChange
attributes of the current element.
value
: A number. Update thevalue
attribute of the current element.min
: A number. Update themin
attribute of the current element.max
: A number. Update themax
attribute of the current element.isTriggerChange
: A Boolean attribute. If its value istrue
, the element will trigger thequantityChange
event.
<div id="text" class="hidden">The `quantityChange` event is triggered.</div>
<spz-quantity
id="quantity"
layout="container"
value="8"
min="1"
max="12"
@quantityChange="text.toggleClass(class='hidden', force=false);"
></spz-quantity>
<button
type="button"
@tap="quantity.update(min=2, max=20, value=11, isTriggerChange=true);"
>
Update quantity
</button>
Events
跳转到“Events”event object data
跳转到“event object data”{
"value": 2, // the current value
"originData": { // original data
"value": 2
}
}
quantityChange
跳转到“quantityChange”Be automatically triggered when the quantity is changed.
quantityChangeToMin
跳转到“quantityChangeToMin”Be automatically triggered when the quantity changes to minimum value.