步骤一
在data初始数据定义isopen:true
步骤二
// 小程序自定义radio
onsChange() {
var that = this
this.setData({
//取反
isopen: !that.data.isopen
})
console.log(that.data.isopen)
},
默认为不选中
点击选中
wxml页面用的三元表达式
复制只需换下你们的图片就可以用
例如默认true,点击false,再点击true
步骤一
在data初始数据定义change:true,
changbtn:‘可爱’
步骤二
changbtn(){
if (this.data.change==true){
this.setData({
changbtn:‘可爱’
})
}else{
this.setData({
changbtn: ‘你不可爱’
})
}
//取反
this.data.change = !this.data.change
},
wxml页面
{
{changbtn}}
默认
再点击