import React, { Component } from ‘react‘
import { View, Text ,Checkbox} from ‘@tarojs/components‘
export default class Index extends Component {
constructor(props){
super(props)
this.state = {
checked:false
}
}
handleClick = ()=>{
this.setState({
checked:!this.state.checked
})
}
render() {
return (
<View>
<Checkbox onClick={this.handleClick} checked={this.state.checked}></Checkbox>
{/* 要toString不然小程序上不显示 */}
是否选中 : {this.state.checked.toString()}
</View>
)
}
}
原文:https://www.cnblogs.com/luguankun/p/13934332.html