背景图片在编辑器中可以展示,但是手机预览时无法显示。
<!-- index.wxml -->
<view class='container'>
<!-- 主体内容 -->
<view class="body_level" style="background:url({{background}});">
<view class="logo_robot" >
<image src='{{logo_robot}}'></image>
</view>
</view>
</view>
//index.js
Page({
data: {
"background" : "/images/mipmap-hdpi/backgr.png", //背景图片
"logo_robot": "../../../images/mipmap-hdpi/logo-robot.png",
},
onLoad: function () {
var that = this;
let base64 = wx.getFileSystemManager().readFileSync(this.data.background, 'base64');
that.setData({
'background': 'data:image/jpg;base64,' + base64
});
},
})