网络图片地址图片更换后,小程序内图片不变
发布于 5 年前 作者 lei28 14911 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)

一个页面有一张图片,图片地址固定。当这个图片被覆盖,文件名不变,有可能导致小程序内显示的图片还是未覆盖之前的。

比如图片路径为http://www.a.com/banner.jpg,上传一张新的图片覆盖该图片以后,小程序内显示的还是旧的图片

  • 预期表现

应该显示覆盖后的新图片

4 回复

这个问题解决了吗?应该是微信的缓存吧?

要么配置服务器不缓存,要么请求的时候随便加个参数,时间戳或者随机数都行,比如:

<image src="{{src}}"></image>

src: “https://www.luxiaoxiao.com/test.png?t=”+new Date().getTime()

set_head() {

    var that = this;

    wx.chooseImage({

      count: 1,

      sizeType: [‘original’, ‘compressed’], //

      sourceType: [‘album’, ‘camera’], //

      success: function (res) {

        wx.cloud.uploadFile({

          cloudPath: ‘user_head/’ + getApp().globalData.id + ‘_head.png’,

          filePath: res.tempFilePaths[0],

          success(res) {

            console.log(res.fileID)////////

            that.setData({

              head: res.fileID

            })

           console.log(that.data.head)////////

            admin.doc(getApp().globalData.id).update({

              data: {

                head:res.fileID

              },

              success: function (res) {

                console.log(‘成功’+that.data.head)/////////

              },

              fail: function (res) {

                console.log(‘失败’+that.data.head)//////////

              }

            })

          }

        })

      }

    })

  },

我也是,求改

你可以动态更换image的url,这样不容易受到缓存的影响

回到顶部