React native development points (continuously updated)

I have been in touch with RN for a while. From a novice to a novice who is not so novice giggle, it is inevitable that during the development process, there will still be many knowledge points that have been forgotten, or that are not easy to write wrong. Maybe one is very Small mistake, I have been looking for a long time and I don't know why. It greatly slows down the development process. Here, I record some mistakes that I easily make, for your reference in the development process!

Well, the text begins:

1. The image component of the network request image is not displayed.

This situation is likely to be:

1. The uri is wrongly written as url. Pay special attention to this, because the url may be correct on iOS and can display pictures, but it is wrong on android, so be sure to use uri

        <Image
          style={[styles.image,]}
          source={{url:"http://h1.ioliu.cn/bing/DuskyDolphin_EN-AU11918143365_1920x1080.jpg"}}>//错误
        </Image>
        <Image
          style={[styles.image,]}
          source={{uri:"http://h1.ioliu.cn/bing/DuskyDolphin_EN-AU11918143365_1920x1080.jpg"}}>//正确
         </Image>

2. The image size is not specified. Many images to be displayed in the App cannot be obtained during compilation, or sometimes dynamic loading is required to reduce the size of the packaged binary file. These times, unlike static resources ,你需要手动指定图片的尺寸

  image:{
    width:192,
    height:108,
    marginBottom: 20
  }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324419612&siteId=291194637