話不多說,效果圖如下:
具體代碼如下:
<radio-group name="radio" bindchange="getSex"><label><radio value="1" checked="{{xingbie==1}}" />男</label><label><radio value="2" checked="{{xingbie==2}}" />女</label>
</radio-group>
js代碼如下:
data: {name: '', //姓名xingbie: '', //性別phone: '', //聯系方式weixin: '', //微信號date: '請選擇', //出生日期xiaoqu: '', //校區desc: '', //備注},// 獲取用戶信息getUserinfo(){getUser().then((res) => {console.log(res,'獲取用戶信息')if (res.code == 200) {this.setData({name:res.data.nickname,xingbie:res.data.sex,//接口返回的就是數字1-2phone:res.data.mobile,weixin:res.data.wx,date:res.data.birthday,xiaoqu:res.data.school,desc:res.data.remark})} else {wx.showToast({title: res.msg})}})}
希望能幫到你們,記得點贊收藏哦!