react-native imageButton 可设置默认图片,避免加载失败空白
来源:互联网 发布:冷核聚变知乎 编辑:程序博客网 时间:2024/05/17 21:45
import React, {Component} from 'react';import {TouchableOpacity, Image} from 'react-native';export default class ImageButton extends Component { render() { return ( <TouchableOpacity activeOpacity={0.9} onPress={this.props.onPress}> {this._renderImg()} </TouchableOpacity> ) } _renderImg(){ if(this.props.defaultSource){ return ( <Image style={this.props.style} source={this.props.defaultSource} > <Image style={this.props.style} source={this.props.source} > {this.props.children} </Image> </Image> ) }else { return ( <Image style={this.props.style} source={this.props.source} > {this.props.children} </Image> ) } }}
使用
<ImageButton defaultSource={require("../img/avatar.png")} source={{uri: item.img}} style={styles.imgStyle} onPress={()=>this._clickItem(item)} >
阅读全文
0 0
- react-native imageButton 可设置默认图片,避免加载失败空白
- React Native加载网络图片失败
- react-native image 设置默认图片
- react-native加载图片
- flex 加载图片失败,设置默认显示图片
- React Native加载图片详解
- React-native之图片设置
- EXT默认空白图片路径设置
- React-Native加载网络图片的问题
- React-native 网络图片无法加载问题
- React native ios图片加载不出来
- React Native 的图片加载方式
- react-native APP Image加载图片
- React-native 网络图片无法加载问题
- 图片加载失败,显示默认图片
- 图片加载失败,显示默认图片
- 如果图片加载失败,显示默认图片
- 图片加载失败显示默认图片
- Android USB Camera(1) : 调试记录
- java 网页参数转换
- 树DP 树上染色
- Map、Set、List、Queue、Stack的特点与用法
- 零售快消品B2B“货圈全”产品分析报告
- react-native imageButton 可设置默认图片,避免加载失败空白
- Java]NIO:使用Channel、Charset(字符集)、使用Charset传递CharBuffer
- Excel设置扩展数据区域实现输入新行自动扩展上行公式
- Collections
- C++ bug tips
- HDU沈阳网络赛:transaction transaction transaction(树形dp & 最短路)
- 第二周项目1-多文件程序的组织(课程主页版)
- Ubuntu16.04安装inetsim模拟Internet
- Redis与Memcached区别