From the WEEx API, we know that the method of loading local images is:

In iOS, Weex looks in bundle Resources. For example, if the SRC attribute of the image component is local:///app_icon', Weex will load the image asset named app_icon from the bundle resouce, and the font file will work in the same way. In Android, the image component is loaded from the drawable resource folder, such as res/drawable -xxx. But loading the font file is different, the Android framework cannot load the font file from RES, so the SDK will load it from the implies folder. (Android friends find their own, because they are not familiar with Android, so do not install force)Copy the code

The above is excerpted from the WEEX document.

However, some friends find that there are problems in the process of using it. The blogger also accidentally stepped on thunder when using it, so here the blogger gives a simple explanation to help those who do not know how to deal with it. The correct method is similar to the above:

<image style="width:150px; Height :150px" SRC ="local://qie.jpeg"></image> It must also be placed in the resource files directory.Copy the code



For example, if your file name is image, you can refer to image as local://image/qie.jpeg. This way, you can use Weex to load local images, isn’t it easy?


As of March 21, 2018, weexpack has been upgraded to 1.1.6, which eliminates the need to write the folder name in the path when creating a folder.