search
HomeWeChat AppletMini Program DevelopmentDetailed explanation of WeChat applet component: radio single selection item

radio single-select item component description:

radio: single-select item.

radio-group:

Single-item selector, internally composed of multiple .

The radio single-select item sample code runs as follows:

Detailed explanation of WeChat applet component: radio single selection item

The following is the WXML code:

<view class="page">
  <view class="page__hd">
    <text class="page__title">radio</text>
    <text class="page__desc">单选框</text>
  </view>
  <view class="page__bd">
    <view class="section section_gap">
      <radio-group class="radio-group" bindchange="radioChange">
        <label class="radio" wx:for="{{items}}">
          <radio value="{{item.name}}" checked="{{item.checked}}"/>{{item.value}}
        </label>
      </radio-group>
    </view>
  </view>
</view>

The following is the JS code:

Page({
  data: {
    items: [
      {name: &#39;USA&#39;, value: &#39;美国&#39;},
      {name: &#39;CHN&#39;, value: &#39;中国&#39;, checked: &#39;true&#39;},
      {name: &#39;BRA&#39;, value: &#39;巴西&#39;},
      {name: &#39;JPN&#39;, value: &#39;日本&#39;},
      {name: &#39;ENG&#39;, value: &#39;英国&#39;},
      {name: &#39;FRA&#39;, value: &#39;法国&#39;},
    ]
  },
  radioChange: function(e) {
    console.log(&#39;radio发生change事件,携带value值为:&#39;, e.detail.value)
  }
})

The following is the WXSS code:

page {
    min-height: 100%;
    flex: 1;
    background-color: #FBF9FE;
    font-size: 32rpx;
    font-family: -apple-system-font,Helvetica Neue,Helvetica,sans-serif;
    overflow: hidden;
}
.page__hd{
    padding: 50rpx 50rpx 100rpx 50rpx;
    text-align: center;
}
.page__title{
    display: inline-block;
    padding: 20rpx 40rpx;
    font-size: 32rpx;
    color: #AAAAAA;
    border-bottom: 1px solid #CCCCCC;
}
.page__desc{
    display: none;
    margin-top: 20rpx;
    font-size: 26rpx;
    color: #BBBBBB;
}
.radio {
  display: block;
  margin-bottom: 20rpx;
}
.section{
    margin-bottom: 80rpx;
}
.section_gap{
    padding: 0 30rpx;
}

The main attributes of the radio single-item item:

radio-group:

Detailed explanation of WeChat applet component: radio single selection item

radio :

Detailed explanation of WeChat applet component: radio single selection item

The above is the detailed content of Detailed explanation of WeChat applet component: radio single selection item. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.