wx.downloadFile({
url: 'https://naobo.lezhihuwa.net/xiaochengxu/images/loginbg.jpg',
success (res) {
if (res.statusCode === 200) {
//console.log("开机音效缓存文件临时地址")
wx.setStorageSync('loginbg', res.tempFilePath)
that.setData({
loginbg:res.tempFilePath
})
}
}
})
前台调用:
<view class="login" style="background-image: url({{loginbg}});">
对应的css样式
.login{
width: 100%;
height: 100vh;
overflow: hidden;
background-repeat: no-repeat;
background-position: left top;
background-size:100% 100%;
}