spz-selector
Layouts
跳转到“Layouts”Usage
跳转到“Usage”- All child elements of the
spz-selector
must have anoption
attribute. - A child element has a
selected
attribute when it is selected.
<spz-selector name="selector" layout="fixed-height" height="48">
<spz-img option="0" layout="fixed" width="48" height="48" src="./images/1.jpg"></spz-img>
<spz-img option="1" layout="fixed" width="48" height="48" src="./images/2.jpg"></spz-img>
<spz-img option="2" layout="fixed" width="48" height="48" src="./images/3.jpg"></spz-img>
</spz-selector>
Attributes
跳转到“Attributes”name
跳转到“name”This attribute is used to specify the name of the control.
disabled
跳转到“disabled”This attribute indicates that the user cannot interact with the control. If this attribute is present, then the control is enabled, and vice versa.
multiple
跳转到“multiple”If this attribute is present, indicates that multiple options can be selected in the list.
default-value
跳转到“default-value”Specifies a selected option with the given default value. It is necessary when the variant-id
is existing.
variant-id
跳转到“variant-id”Specifies the spz-variant
id.
Actions
跳转到“Actions”update
跳转到“update”update(data=<Object>)
Use the passed data to render the template content when the element has a template. It has a parameter:
data
: required. A Object attribute. Re-render the template data.
clear
跳转到“clear”Remove all selected options. No parameter required.
<button type="button" @tap="selector.clear">Clear All options</button>
toggle
跳转到“toggle”toggle(option=<Number>[, value=<Boolean>])
The option specified by toggle is between selection and non-selection.
option
: required. Aoption
value that specifies the element currently to be toggled.value
: Specify whether to selected. If its value istrue
, select the element of the current option.
<button type="button" id="button" @tap="selector.toggle(option=2)">Toggle the second option</button>
Events
跳转到“Events”event object data
跳转到“event object data”{
"eventName": "mouseover", // the current trigger event name
"name": "image-selector", // the current name attribute value
"targetOption": "2", // the current option value
"selectedOptions": [], // the current selected options
"defaultValue": null,
"originData": { // original data
// ...
}
}
mounted
跳转到“mounted”Be automatically triggered when the element is mounted, and the default-value
is present.
select
跳转到“select”Be automatically triggered when selecting an option.
mouseover
跳转到“mouseover”Be automatically triggered when a user is an option to the mouse over.
<spz-render id="render" layout="container" manual>
<template>
<div>
<span>The selected option is ${data.targetOption}</span>
</div>
</template>
</spz-render>
<spz-selector
name="image-selector"
layout="fixed-height"
height="48"
@mouseover="render.rerender(data=event);"
>
<spz-img option="0" layout="fixed" width="48" height="48" src="./images/1.jpg"></spz-img>
<spz-img option="1" layout="fixed" width="48" height="48" src="./images/2.jpg"></spz-img>
<spz-img option="2" layout="fixed" width="48" height="48" src="./images/3.jpg"></spz-img>
</spz-selector>
mouseout
跳转到“mouseout”Be automatically triggered when a user is an option to the mouse out.