fix: 修复文章详情无法展示图片的bug
This commit is contained in:
parent
e520f33d7c
commit
81758accdc
@ -28,6 +28,11 @@
|
|||||||
getDetail(e.id)
|
getDetail(e.id)
|
||||||
})
|
})
|
||||||
// 变量
|
// 变量
|
||||||
|
let strings = `<div style="text-align: center; "><p> 测试内容222sdadd </p><figure class="image"><img src="https://jmyl-app.oss-cn-chengdu.aliyuncs.com/miniapp/uploads/2024-02-24/undone.png"/></figure></div>`
|
||||||
|
// `<p> 测试内容222sdadd </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 userInfo = ref(null)
|
||||||
// const content = ref(null)
|
// const content = ref(null)
|
||||||
const a_info = ref(null)
|
const a_info = ref(null)
|
||||||
@ -36,6 +41,10 @@
|
|||||||
const res = await api.getArticleDetail({id})
|
const res = await api.getArticleDetail({id})
|
||||||
if(res.code == 0) {
|
if(res.code == 0) {
|
||||||
a_info.value = res.data
|
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{
|
else{
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
@ -67,15 +76,19 @@
|
|||||||
}
|
}
|
||||||
a_info.value.is_favorite = type
|
a_info.value.is_favorite = type
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<view class="detailBox">
|
<view class="detailBox">
|
||||||
<view class="title">
|
<view class="title">
|
||||||
{{a_info?.title}}
|
{{a_info?.title}}
|
||||||
</view>
|
</view>
|
||||||
<view v-if="a_info" class="more-info small-text">{{util.timestampToDate(a_info?.CreatedAt)}}</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="action-box" v-if="a_info">
|
||||||
<view class="ab-item">
|
<view class="ab-item">
|
||||||
<uni-icons color="gray" type="eye" size="30"></uni-icons>
|
<uni-icons color="gray" type="eye" size="30"></uni-icons>
|
||||||
@ -87,8 +100,8 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<emptyCard title="暂无内容" v-if="!a_info"></emptyCard>
|
<emptyCard title="暂无内容" v-if="!a_info"></emptyCard>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.action-box{
|
.action-box{
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
@ -115,5 +128,5 @@
|
|||||||
.d-content{
|
.d-content{
|
||||||
line-height: 50rpx;
|
line-height: 50rpx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue
Block a user