|
|
|
@ -13,7 +13,7 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<rich-text :nodes="content" v-if="$isRight(content)"></rich-text> |
|
|
|
<rich-text :nodes="formatRichText(content)" v-if="$isRight(content)"></rich-text> |
|
|
|
<lf-nocontent v-else></lf-nocontent> |
|
|
|
<!-- 回到顶部 --> |
|
|
|
<u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top> |
|
|
|
@ -36,6 +36,26 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 富文本处理 |
|
|
|
formatRichText(richText){ |
|
|
|
if(richText != null){ |
|
|
|
let newRichText= richText.replace(/<img[^>]*>/gi, function(match, capture){ |
|
|
|
match = match.replace(/style="[^"]+"/gi, '').replace(/style='[^']+'/gi, ''); |
|
|
|
match = match.replace(/width="[^"]+"/gi, '').replace(/width='[^']+'/gi, ''); |
|
|
|
match = match.replace(/height="[^"]+"/gi, '').replace(/height='[^']+'/gi, ''); |
|
|
|
return match; |
|
|
|
}); |
|
|
|
newRichText = newRichText.replace(/style="[^"]+"/gi,function(match, capture){ |
|
|
|
match = match.replace(/width:[^;]+;/gi, 'width:100%;').replace(/width:[^;]+;/gi, 'width:100%;'); |
|
|
|
return match; |
|
|
|
}); |
|
|
|
newRichText = newRichText.replace(/<br[^>]*\/>/gi, ''); |
|
|
|
newRichText = newRichText.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;margin:10px 0;"'); |
|
|
|
return newRichText; |
|
|
|
}else{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
}, |
|
|
|
getData(){ |
|
|
|
this.$http(this.API.API_MESSAGEDETAILS,{id: this.news_id}).then(res => { |
|
|
|
this.content = res.data?.content; |
|
|
|
|