部分代码:<import src="…/…/wxParse/wxParse.wxml"/>
<view class=“wxParse”>
<template is=“wxParse” data="{{wxParseData:article.nodes}}"/>
</view>
getArticle:function(id){
var that=this;
wx.request({
url: ‘http://mini.eastday.com/mobile/’+id+’.html’,
data: {},
method: ‘GET’, // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
// header: {}, // 设置请求的 header
success: function(res){
WxParse.wxParse(‘article’, ‘html’, res.data, that);
// success
console.log(res);
},
fail: function(res) {
// fail
},
complete: function(res) {
// complete
}
})
},
wxParse.wxml文件:
< image class = "{{item.classStr}} wxParse-{{item.tag}}" data-from = "{{item.from}}" data-src = "{{item.attr.src}}" data-idx = "{{item.imgIndex}}" src = "{{item.attr.src}}" mode = "aspectFit" bindload = "wxParseImgLoad" bindtap = "wxParseImgTap" mode = "widthFix" style = "width:{{item.width}}px;" /> |
最后的 style=“width:{{item.width}}px;” 改为 style=“width:100%;”