wxml
<rich-text wx:if="{{!isLoading && content}}" nodes="{{content}}" catchtap="richTextClick"></rich-text>
<view class="empty" wx:if="{{!isLoading && !content}}">暂无数据</view>
js
// 富文本点击事件
richTextClick() {
// 富文本
const richContent = this.data.content;
// 判断含有图片
if (richContent.indexOf("src") >= 0) {
const imgs = [];
richContent.replace(/]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
imgs.push(capture);
})
wx.previewImage({
current: imgs[0], // 当前显示图片的链接
urls: imgs
})
}
},