美文网首页
ReactNative入门之iOS Image无法显示http图

ReactNative入门之iOS Image无法显示http图

作者: OneByte | 来源:发表于2017-03-30 10:34 被阅读2134次

    准备入门ReactNative, 写了个Image显示网络图片的

    import React from 'react';
    import {Image,View,AppRegistry} from 'react-native';
    
    export default class App extends React.Component{
      render(){
          let picUrl = {
              uri: "http://xxxx.jpg"
          }
          return (
            <View style={{backgroundColor: 'red'}}>
                <Image source={picUrl} style={{width: 193, height: 210}}/>
            </View>
          );
      };
    }
    AppRegistry.registerComponent('HelloWorld', () => App);
    

    运行在iOS模拟器上,无法显示图片,2种解决方案:

    1. uri 整个 https 的网络图片路径,搞定!

    2. Info.list加个Allow Arbitrary Loads -> Yes
      模拟器上 系统设置(Settings) -> Developer -> Allow HTTP Services这个打开

    相关文章

      网友评论

          本文标题:ReactNative入门之iOS Image无法显示http图

          本文链接:https://www.haomeiwen.com/subject/cgyuottx.html