本文實例講述了微信小程序使用radio顯示單選項功能。分享給大家供大家參考,具體如下:
1、效果展示

2、關(guān)鍵代碼
① index.wxml
<radio-group bindchange="radiogroupBindchange"> <radio value="radio1">radio1</radio> <radio value="radio2">radio2</radio> <radio value="radio3">radio3</radio></radio-group><view>提示:{{text}}</view>② index.js
Page({ data:{ // text:"這是一個頁面" text:'' }, radiogroupBindchange:function(e){ console.log(e); this.setData({ text:'您選擇了'+e.detail.value }) }})3、源代碼點擊此處本站下載。
關(guān)于radio組件的更多詳細(xì)說明還可參考官網(wǎng):https://mp.weixin.qq.com/debug/wxadoc/dev/component/radio.html
希望本文所述對大家微信小程序開發(fā)有所幫助。
新聞熱點
疑難解答