Switch selector for WeChat applet component interpretation and analysis

Source: Internet
Author: User
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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.