微信小程序使用wxparse,有一个问题,就是我们在网页后台编辑器里面的图片如果上传的时候采用了相对路径,在wxparse里就不能正常显示,但是,如果在编辑器里直接上传成绝对的网络地址路径之后,如果万一以后换域名了。也是个问题。所以最好的方式就是让wxparse在使用的时候,自动添加域名前缀就可以了。

所以需要改动这个文件:html2json.js 

这个文件的这段代码的imgurl,前面加一个你的域名,这样在你使用的时候,就会自动添加上域名了。

亲测,可以用。

 

 

//对img添加额外数据  
          if (node.tag === 'img') {  
              node.imgIndex = results.images.length;  
              var imgUrl = “http://www.baidu.com(这块换成你的域名地址前缀就可以了)”+node.attr.src;  
              if (imgUrl[0] == '') {  
                  imgUrl.splice(0, 1);  
              }  
              imgUrl = wxDiscode.urlToHttpUrl(imgUrl, __placeImgeUrlHttps);  
              node.attr.src = imgUrl;  
              node.from = bindName;  
              results.images.push(node);  
              results.imageUrls.push(imgUrl);  
          }  

 

相关文章:

  • 2021-11-23
  • 2021-11-27
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-07-28
猜你喜欢
  • 2021-08-27
  • 2021-09-04
  • 2021-05-17
  • 2022-01-21
  • 2021-11-17
  • 2021-03-31
  • 2022-12-23
相关资源
相似解决方案