微信小程序使用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);            }

TAG标签: 微信小程序链接前缀

http://www.xiaochengxub.com/read-102881.html