React切换显示和隐藏
1 {radioChange >= 0 &&
2 <div>
3 {radioChange === 0 ? (
4 <div className={style.template} key="1">
5 <div className={style.inline}>如果金额超过</div>
6 <Input className={style.input} label=" " id="free_price" rules={['required']}
7 msg={this.msg} style={{ width: '100px', display: 'inlinbe-block' }} />
8 <div className={style.inline}>元,免运费,否则按照公里数收取,每公里</div>
9 <Input className={style.input} label=" " id="unit_price" rules={['required']}
10 msg={this.msg} style={{ width: '100px', display: 'inlinbe-block' }} />
11 <div className={style.inline}>元,最多不超过</div>
12 <Input className={style.input} label=" " id="max_price" rules={['required']}
13 msg={this.msg} style={{ width: '100px', display: 'inlinbe-block' }} />
14 <div className={style.inline}>元</div>
15 </div>
16 )
17 : (
18 <div className={style.template} key="2">
19 <div className={style.inline}>如果金额超过</div>
20 <Input className={style.input} label=" " id="free_price" rules={['required']}
21 msg={this.msg} style={{ width: '100px', display: 'inlinbe-block' }} />
22 <div className={style.inline}>元,免运费,否则一口价</div>
23 <Input className={style.input} label=" " id="price" rules={['required']}
24 msg={this.msg} style={{ width: '100px', display: 'inlinbe-block' }} />
25 <div className={style.inline}>元</div>
26 </div>)
27
28 }
29 </div>
- 如上面代码显示,如果通过一个数值控制,显示和隐藏切换的话,必须加入一个key值,否则在切换的时候活报错,应该是在页面渲染的时候会重复利用这个元素,如果加入keys,渲染的时候,不会产生复用
React切换显示和隐藏的更多相关文章
- toggle显示与隐藏切换
jQuery中显示与隐藏切换toggle方法 show与hide是一对互斥的方法.需要对元素进行显示隐藏的互斥切换,通常情况是需要先判断元素的display状态,然后调用其对应的处理方法.比如显示的元 ...
- js 与JQuery显示及隐藏方法
虽然以后两种方式都能让文本信息隐藏和显示 第一种文本隐藏以后还是会占居位置, 第二种则不会占位置. <p id="p1">这是一段文本.</p> <i ...
- WordPress添加显示和隐藏侧边栏按钮开关
在很多的地方都看见过这种效果,就是在文章页面可以切换显示和隐藏侧边栏功能,感觉还是很有用,比如一篇文章的文字内容过多,那么就可以通过隐藏侧边栏来显示更多的文字便于浏览.比如你可以通过点击我文章标题下方 ...
- jQuery效果之显示与隐藏
.hide([duration][,complete])--目标元素的隐藏. .show([duration][,complete])--目标元素的显示: .toggle([duration][,co ...
- VUE中登录密码显示与隐藏的最简设计——基于iview
目录 VUE中登录密码显示与隐藏的最简设计--基于iview 1.背景 2.实现最终效果 2.1 隐藏密码 2.2 显示密码 3.实现思路 3.1 v-if判断当前密码显示状态 3.2 密码隐藏状态 ...
- react中控制元素的显示与隐藏
1.通过 state 变量来控制是否渲染元素 类似于 vue 的 v-if 方法是通过变量来控制是否加载元素的,如果变量为false,内容就直接不会渲染的. class Demo extends Re ...
- Android文本输入框(EditText)切换密码的显示与隐藏
package cc.c; import android.app.Activity; import android.os.Bundle; import android.text.Selection; ...
- React+Ant Design设置左侧菜单导航路由的显示与隐藏(与权限无关)
最近在学习react时,用到了很流行的UI框架Ant Design,也了解了一下Ant Design Pro,发现它们都有导航组件,Ant Design框架的导航菜单在这里,Ant Design Pr ...
- jQuery控制元素显示、隐藏、切换、滑动的方法
jQuery 隐藏和显示 通过 hide() 和 show() 两个函数,jQuery 支持对 HTML 元素的隐藏和显示: 实例 $("#hide").click(functio ...
随机推荐
- Mysql索引学习笔记
1.btree索引与hash索引 下列范围查询适用于 btree索引和hash索引: SELECT * FROM t1 WHERE key_col = 1 OR key_col IN (15,18,2 ...
- 论文笔记:Progressive Differentiable Architecture Search:Bridging the Depth Gap between Search and Evaluation
Progressive Differentiable Architecture Search:Bridging the Depth Gap between Search and Evaluation ...
- JavaScript:直接写入 HTML 输出流
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- 记录使用antd时样式不生效的问题
最近在学webpack,就配置了一个react的运行环境,为了偷懒使用了antd npm install antd 之后发现竟然tmd没有样式 谷歌之后发现好多同学都出现了这个问题,好在最后解决了 在 ...
- spring入门(一) 根据xml实例化一个对象
文档: https://docs.spring.io/spring/docs/5.0.9.RELEASE/spring-framework-reference/core.html#beans-fact ...
- c# Hash一致算法负载均衡(KetamaHash)项目升级
其实就是我最近写的一个项目,采用Hash一致满足负载均衡.Hash一致环带虚拟节点. 在前面的博文中说明了我采用的方法,MurmurHash+红黑树(底层其实是sortedlist).经过多次测试结合 ...
- JS定时器和单线程异步特性
首先要说的是,定时器相关的方法都是属于BOM方法,而定时器呢,它是用于在设定的时间执行一段代码,或者在给定的时间间隔内重复该代码.具体函数: setTimeout(callback, delay);/ ...
- Shiro登录中遇到了问题
Shiro登录中遇到了问题 记录二次开发中遇到的问题, 如果系统学习Shiro, 推荐跟我学Shrio. 问题 项目是要将验证从本地改为LDAP验证, 但是因为jeecms的验证和授权中, 用户和角色 ...
- 【TOJ 3005】Triangle(判断点是否在三角形内+卡精度)
描述 Given the coordinates of the vertices of a triangle,And a point. You just need to judge whether t ...
- Linux 安装 python 指定版本--编译源码方式
自动化脚本: #!/bin/bash sudo apt-get update sudo apt-get install -y gcc make build-essential libssl-dev z ...