The switch selector is interpreted and analyzed by the applet component,
Switch selector component description:
Switch: The switch Selector. Select only or not. This is a form control or query condition control.
The sample code of the switch selector runs as follows:
The following is the WXML code:
[XML]View plain text Copy code
Switch style
Switch style
Checkbox style
Checkbox style
Who are there in travel to the West?
Niumo Wang
Sun Wukong
Pig
Qimu kakaxi
The following is the JS code:
[JavaScript]View plain text Copy code
Page ({switch1Change: function (e) {console. log ('switch event occurs in switask', with the carrying value ', e. detail. value)}, switch2Change: function (e) {console. log ('switch2 has a change event, with a value of ', e. detail. value )}})
The following is the WXSS code:
[CSS]View plain text Copy code
.page { min-height: 100%; flex: 1; background-color: #FBF9FE; font-size: 32rpx; overflow: hidden;}
Main attribute of the switch Selector
Attribute name |
Type |
Default value |
Description |
| Checked |
Boolean |
False |
Selected? |
| Type |
String |
Switch |
Style, valid values: switch, checkbox |
| Bindchange |
EventHandle |
|
The change event is triggered when the checked changes. event. detail = {value: checked} |
Personal experience: it is applicable to selecting true or false for a single item. the checkbox style is not recommended.
This applies to selecting true or false for a single item. the checkbox style is not recommended. Because the checkbox control already exists. In addition, this kind of checkbox style does not contain the text behind it. I have pieced together the above picture, and there is no control event yet (this should not be used)
The above is the details of the switch Selector, which is interpreted and analyzed by the applet components. For more information, see other related articles in the first PHP community!