About getting the value of whether a single checkbox is selected in the WeChat applet

1. The use of a single CheckBox

It is generally used to do a single check box similar to the remember password function when you need to get whether it is selected or not

wxml part
//wxml
<checkbox-groupbindchange="niming">  
<view class='check-box'>
< checkbox value = "Anonymous" value = 'Anonymous' / > Anonymous    
</view>
</checkbox-group>


js part
//js
/ / Determine whether it is selected by judging whether the value value is empty when changing the state  
niming:function(e){
if (e.detail.value =='') {
check = 0
}
else {
check = 1
}

console.log(e.detail.value);
console.log(check);
},

check as a global js variable, the initialized value is set to 0, that is, the unselected state, you can also use boolean (false, true) to indicate 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325843472&siteId=291194637