小程序官方API:https://developers.weixin.qq.com/miniprogram/dev/component/image.html
1:加载本地文件夹图片
<image src="/image/pig.jpg" mode="aspectFill">
</image>

图片.png
2:加载服务器图片
wxml:
<image src="{{imageUrl}}" mode="aspectFill">
</image>
js:
Page({
data: {
imageUrl: "http://www.intmote.com/timg.jpg",
},

图片.png
或者直接在wxml写代码:
<image src="http://www.intmote.com/timg.jpg" mode="aspectFill">
</image>

图片.png
3:给小程序页面加载一张背景图片
方法一:
使用背景图片的时候用网络图片,就是用外链的形式,比如你将这张图片放到你的服务器,如:https://xxxx/xxx.jpg;
方法二:
将背景图片使用编码base64进行转换,可以在这个网址进行http://tool.css-js.com/base64.html 转换,如:background-image: url("转换后得到的编码文本"),如果多次使用的话可以将该值设置为全局变量,再在js文件进行引用即可;
详见上一篇博客:https://www.jianshu.com/p/61e6e7390f4a
原文作者:祈澈姑娘
技术博客:https://www.jianshu.com/u/05f416aefbe190后前端妹子,爱编程,爱运营,爱折腾。
坚持总结工作中遇到的技术问题,坚持记录工作中所所思所见,欢迎大家加入群聊,一起探讨交流。