W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
單項(xiàng)選擇器組,內(nèi)部由多個 radio 組成。
<!-- API-DEMO page/component/radio/radio.axml -->
<view class="page">
<view class="page-description">單選框</view>
<view class="page-section">
<view class="section section_gap">
<form onSubmit="onSubmit" onReset="onReset">
<view class="page-section-demo">
<radio-group class="radio-group" onChange="radioChange" name="lib">
<label class="radio" a:for="{{items}}" key="label-{{index}}">
<radio value="{{item.name}}" checked="{{item.checked}}" disabled="{{item.disabled}}" />
<text class="radio-text">{{item.value}}</text>
</label>
</radio-group>
</view>
<view class="page-section-btns">
<view><button size="mini" type="ghost" formType="reset">reset</button></view>
<view><button size="mini" type="primary" formType="submit">submit</button></view>
</view>
</form>
</view>
</view>
</view>
// API-DEMO page/component/radio/radio.js
Page({
data: {
items: [
{ name: 'angular', value: 'AngularJS' },
{ name: 'react', value: 'React', checked: true },
{ name: 'polymer', value: 'Polymer' },
{ name: 'vue', value: 'Vue.js' },
{ name: 'ember', value: 'Ember.js' },
{ name: 'backbone', value: 'Backbone.js', disabled: true },
],
},
onSubmit(e) {
my.alert({
content: e.detail.value.lib,
});
console.log('onSubmit', e.detail);
},
onReset(e) {
console.log('onReset', e);
},
radioChange(e) {
console.log('你選擇的框架是:', e.detail.value);
},
});
/* API-DEMO page/component/radio/radio.acss */
.radio {
display: block;
margin-bottom: 20rpx;
}
.radio-text {
line-height: 1.8;
}
屬性 | 類型 | 描述 |
---|---|---|
onChange | EventHandle | 選中項(xiàng)發(fā)生變化時觸發(fā),event.detail = {value: 選中項(xiàng) radio 的 value}。 |
name | String | 組件名字,用于表單提交獲取數(shù)據(jù)。 |
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: