1.React Native 中如何实现根据state控制组件的显示与隐藏?
render() {
return(
{
this.state.abc == null ? (
null
) : (
<View>
//不为空时想要显示的内容
<View>
)
}
)
}
2.通过Modal定义的弹框,有两个不足:
(1)背景透明层也是Modal的一部分,如果animationType是slide方式,则透明背景会一起滑动,体验很不友好,fade模式相对好点.
(2)没有类似于原生的的setCancelable方法,不过我们可以模拟实现这种效果,就是在透明区域加一层view,点击该层view则close当前modal.
3.加载gif图
(1)在android/app/build.gradle中的dependencies字段中添加: compile 'com.facebook.fresco:animated-gif:0.13.0'
(2)编写代码,是不是如此简单
<Image style={{width: 80, height: 80}} source={require('./img/loading.gif')} />
4.如果这样写"export class Xxxx extends Component",在export和class之间丢掉default,程序不会报错,页面加载不出来
未完待续...