您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

react native怎么隐藏组件

2024/11/1 18:34:26发布32次查看
react native隐藏组件可以通过“display:none/flex”属性来实现,其具体实现方法是:1、打开相应的react文件;2、创建“db2cda8a4506690159c677fab885a7c3”;3、通过点击button,修改state的状态来实现隐藏组件即可。
本教程操作环境:windows10系统、react18.0.0版、dell g3电脑。
react native 中如何对组件进行隐藏?
具体问题描述:
如何通过a中的switchandroid的value来控制b模块的显示和隐藏呢显示全部
问题解决方案:
展开,收起功能的实现: display: none / flex
点击button,修改state的状态,从而展示/隐藏 控件
state = {displayshuoming:'none',btnshuoming:'>'};scrollshuoming =()=>{let dis = this.state.displayshuoming;if(dis == 'none'){this.setstate({displayshuoming:'flex',btnshuoming:'>'})}else{this.setstate({displayshuoming:'none',btnshuoming:'v'})}}render(){return (<view style={[styles.bg_white,styles.flex_col,styles.pl_20,styles.pr_20,styles.mt_10]}><view style={[styles.flex_row,styles.bg_white,styles.mt_10,styles.pb_10]}><text style={[styles.flex_3]}>产品说明</text><button color='#ddd' style={{color:'#ccc'}} title={this.state.btnshuoming} onpress={this.scrollshuoming}/></view><view style={{display:this.state.displayshuoming}}><view style={[styles.flex_col,styles.border_top,styles.pt_10]}><text style={[styles.text_gray]}>投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;投资资金安全由保险公司承保;</text></view></view></view>)}
推荐学习:《react视频教程》
以上就是react native怎么隐藏组件的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product