繁体   English   中英

图像不会始终加载到网络中的本机图像组件中

[英]Image does not load always in react native image component from network

来自网络的图像并不总是加载,有时加载,有时却不加载。下面是我的渲染方法。

render() {
let {title, image, text, publisher, id, date} = this.props.webDetail;
let dateString = Moment(date).format('dddd, MMMM Do YYYY');
let metaDetail = `${publisher}\n${dateString}`;

    return (
        <View style={styles.container}>
          <ScrollView showsVerticalScrollIndicator={false}>
              <Text style={styles.title}>{title}</Text>
              <Text style={styles.publisher}>{metaDetail}</Text>
              <Image
                 style={styles.image}
                 source={{ uri: image }} indicator={Progress}
              />
               <Text style={styles.text}>{text}</Text>
              {this.renderButton.call(this) }
         </ScrollView>
      </View>
    );
}

并且图像在提要对象中传递。 调用父级的touch事件时,提要对象将作为道具传递给子级。

 renderContent(feed) {
    let dateString = Moment(feed.date).format('dddd, MMMM Do YYYY');
    let metaDetail = `${feed.publisher}\n${dateString}`;

    return (
        <ScrollView showsVerticalScrollIndicator={false}>
            <Text style={styles.title}>{feed.title}</Text>
            <Text style={styles.publisher}>{metaDetail}</Text>
            <TouchableWithoutFeedback
                onPress={this.onPress.bind(this, feed) }>
                <Image style={styles.image} key={feed.image} source={{ uri: `${feed.image}?version=outside` }} indicator={Progress} />
            </TouchableWithoutFeedback>
            <Text numberOfLines={7} style={styles.text}>{feed.description}</Text>
            <Share rank={feed.rank}/>
        </ScrollView>

    );
}

可能是壁画缓存问题,请尝试通过在图像url上添加随机数来使每次url唯一: imageUrl + ?"+new Date().getTime()

壁画和图像存在各种问题,例如: https : //github.com/facebook/react-native/issues/8677

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM