解决了吗,同问
异步加载图片出现Failed to load image无法加载图片问题,请问怎么解决?相关帖无法解图片链接复制到浏览器正常显示,直接卸载src标签里面也可以正常显示,求指教! 服务器自己的,没开防盗链!!! 报错提示 Failed to load image https://www.kjch.xyz/update2/images/wx90694dade63fe709.o6zAJs6GT7ALFlx70UXyHFtL_xuU.lkPgh3cgzSpG2f3d906f016e21895d4ade0976ff6d5c.png the server responded with a status of 404 (HTTP/1.1 404) From server 120.79.54.134 完整代码 [代码]<!--index.wxml-->[代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"container"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]button[代码] [代码]bindtap[代码][代码]=[代码][代码]'chooseImageTap'[代码][代码]>上传图片</[代码][代码]button[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]wx:if[代码][代码]=[代码][代码]"{{xyz!=null}}"[代码][代码]>[代码][代码] [代码][代码]<!--<image src="{{(xyz)?xyz:'640.jpg;'}}"></image>-->[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]src[代码][代码]=[代码][代码]"{{xyz}}"[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码] [代码][代码]{{xyz}}[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码] [代码]</[代码][代码]view[代码][代码]>[代码]JS代码 [代码]//index.js[代码][代码]Page({[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 页面的初始数据[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]imgs: [],[代码][代码]//本地图片地址数组[代码][代码] [代码][代码]picPaths: [],[代码][代码]//网络路径[代码][代码] [代码][代码]xyz: [代码][代码]"null"[代码][代码],[代码][代码] [代码][代码]abc: [代码][代码]null[代码][代码] [代码][代码]},[代码] [代码] [代码][代码]/**[代码][代码] [代码][代码]* 生命周期函数--监听页面加载[代码][代码] [代码][代码]*/[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码](options) {[代码] [代码] [代码][代码]},[代码][代码] [代码][代码]//添加上传图片[代码][代码] [代码][代码]chooseImageTap: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]wx.showActionSheet({[代码][代码] [代码][代码]itemList: [[代码][代码]'从相册中选择'[代码][代码], [代码][代码]'拍照'[代码][代码]],[代码][代码] [代码][代码]itemColor: [代码][代码]"#00000"[代码][代码],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]if[代码] [代码](!res.cancel) {[代码][代码] [代码][代码]if[代码] [代码](res.tapIndex == 0) {[代码][代码] [代码][代码]that.chooseWxImage([代码][代码]'album'[代码][代码])[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]if[代码] [代码](res.tapIndex == 1) {[代码][代码] [代码][代码]that.chooseWxImage([代码][代码]'camera'[代码][代码])[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]// 图片本地路径[代码][代码] [代码][代码]chooseWxImage: [代码][代码]function[代码] [代码](type) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]imgsPaths = that.data.imgs;[代码][代码] [代码][代码]wx.chooseImage({[代码][代码] [代码][代码]sizeType: [[代码][代码]'original'[代码][代码], [代码][代码]'compressed'[代码][代码]],[代码][代码] [代码][代码]sourceType: [type],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res.tempFilePaths[0]);[代码][代码] [代码][代码]that.upImgs(res.tempFilePaths[0], 0) [代码][代码]//调用上传方法[代码][代码] [代码][代码]console.log(res.tempFilePaths[0])[代码][代码] [代码][代码]that.abc(res.tempFilePaths[0])[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//上传服务器[代码][代码] [代码][代码]upImgs: [代码][代码]function[代码] [代码](imgurl, index) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]wx.uploadFile({[代码][代码] [代码][代码]url: [代码][代码]'https://www.kjch.xyz/update2/uploadFile.do'[代码][代码],//[代码][代码] [代码][代码]filePath: imgurl,[代码][代码] [代码][代码]name: [代码][代码]'file'[代码][代码],[代码][代码] [代码][代码]header: {[代码][代码] [代码][代码]'content-type'[代码][代码]: [代码][代码]'multipart/form-data'[代码][代码] [代码][代码]},[代码][代码] [代码][代码]formData: [代码][代码]null[代码][代码],[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log([代码][代码]"返回值:"[代码] [代码]+ res) [代码][代码]//接口返回网络路径[代码][代码] [代码][代码]var[代码] [代码]data = JSON.parse(res.data)[代码][代码] [代码][代码]that.data.picPaths.push(data[[代码][代码]'msg'[代码][代码]])[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]picPaths: that.data.picPaths,[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log(that.data.picPaths)[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]abc: [代码][代码]function[代码] [代码](e) {[代码][代码]//该函数用于和后台交互[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: [代码][代码]'https://www.kjch.xyz/update2/url'[代码][代码], //仅为示例,并非真实的接口地址[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]URL: e,[代码][代码] [代码][代码]},[代码][代码] [代码][代码]header: {[代码][代码] [代码][代码]'content-type'[代码][代码]: [代码][代码]'application/json'[代码] [代码]// 默认值[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success(res) {[代码][代码] [代码][代码]console.log([代码][代码]"abc返回值:"[代码] [代码]+ res.data);[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]xyz: res.data[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]console.log(that.xyz)[代码][代码] [代码][代码]}[代码] [代码]})[代码] 报错提示: [图片]
2021-04-15