评论

微信小程序使用 linear-gradient 渐变本地图片不显示

微信小程序使用 linear-gradient 渐变本地图片不显示

  // 处理成base64位

  getBase64ImageFile() {

    const _this = this;

    const fileSystemManager = wx.getFileSystemManager();

    fileSystemManager.readFile({

      filePath: filePath,

      encoding: 'base64',

      success(res) {

        _this.setData({

          backgroundurl: `linear-gradient(to bottom,transparent, rgba(255,255,255,0.1) 90%,rgba(255,255,255,1)) , url('data:image/jpg;base64,${res.data}')`,

        });

      },

      fail(err) {

        console.log(err);

      },

    });

  },

解决办法将本地图片处理为base64 数据,background 本地图片支持base64为数据流和ur地址,这里处理为了base64位数据

代码片段 https://developers.weixin.qq.com/s/geWqJfmU7SSu

最后一次编辑于  06-27  
点赞 0
收藏
评论
登录 后发表内容