fix: 修复文章详情无法展示图片的bug

This commit is contained in:
阿怪 2024-02-28 01:26:27 +08:00
parent e520f33d7c
commit 81758accdc

View File

@ -28,6 +28,11 @@
getDetail(e.id)
})
//
let strings = `<div style="text-align: center; "><p>&nbsp;测试内容222sdadd&nbsp;</p><figure class="image"><img src="https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/uploads/2024-02-24/undone.png"/></figure></div>`
// `<p>&nbsp;222sdadd&nbsp;</p><figure class="image"><img src="https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/uploads/2024-02-24/undone.png"></figure>`
// strings = strings.replaceAll("figure", "div");
// strings = strings.replaceAll("<img", "<img style='width:100%'");
console.log(strings)
const userInfo = ref(null)
// const content = ref(null)
const a_info = ref(null)
@ -36,6 +41,10 @@
const res = await api.getArticleDetail({id})
if(res.code == 0) {
a_info.value = res.data
if(a_info.value.content) {
a_info.value.content = a_info.value.content.replaceAll("figure", "div");
a_info.value.content = a_info.value.content.replaceAll("<img", "<img style='width:100%'");
}
}
else{
uni.showToast({
@ -75,7 +84,11 @@
{{a_info?.title}}
</view>
<view v-if="a_info" class="more-info small-text">{{util.timestampToDate(a_info?.CreatedAt)}}</view>
<view class="d-content" v-html="a_info?.content"></view>
<!-- <view class="d-content">
<rich-text :nodes="a_info?.content"></rich-text>
</view> -->
<view v-if="a_info" class="d-content" v-html="a_info.content">
</view>
<view class="action-box" v-if="a_info">
<view class="ab-item">
<uni-icons color="gray" type="eye" size="30"></uni-icons>