背景圖片在編輯器中可以展示,但是手機(jī)預(yù)覽時(shí)無(wú)法顯示近刘。
<!-- index.wxml -->
<view class='container'>
<!-- 主體內(nèi)容 -->
<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
});
},
})