微信小程序设置本地图片的背景,开发工具可以,手机端不显示

  let base64 = wx.getFileSystemManager().readFileSync('/images/videoCover.jpg', 'base64')

          this.setData({

            coverImg: 'data:image/jpg;base64,' + base64,

          })

原因:小程序背景图片只可以展示base64或者网络地址图片,背景图片如果使用路径地址,电脑开发时可以正常显示,手机测试时无法显示背景图。
使用"wx.getFileSystemManager().readFileSync(file_address,encoding)"进行转码https://blog.csdn.net/qq_36875339/article/details/81086205

微信小程序:背景图片电脑开发时可以显示,手机测试时无法显示 - 简书

猜你喜欢

转载自blog.csdn.net/aleluye/article/details/128096917