云开发图片模拟器可以读取,但是真机测试不可以读取出来?
发布于 5 年前 作者 ycai 4467 次浏览 来自 官方Issues

这是按钮组件wxml的内容

<button

bindtap=“Uploverimg”

class=“lover-avatar”

style=“background-image: url({{loveravatarUrl}})”

></button>

然后代码是

wx.cloud.downloadFile({

fileID: app.globalData.loveravatarUrl,

success: res => {

// 返回临时文件路径

console.log(res.tempFilePath)

this.setData({

loveravatarUrl: res.tempFilePath

})

onLoad();

},

fail: console.error

})

日志中都就可以打出来临时文件的路径了,但是手机中就是不显示,这是什么问题?

1 回复

好了,问题已经解决,使用

wx.cloud.getTempFileURL({
  fileList: ['cloud://xxx', 'cloud://yyy'],
  success: res => {
    // get temp file URL
    console.log(res.fileList)
  },
  fail: err => {
    // handle error

 }})


拿临时URL就可以了

回到顶部