lanan-repair/pages/home/content.vue

48 lines
963 B
Vue
Raw Normal View History

2024-09-27 17:19:46 +08:00
<template>
<view class="container">
<web-view :src="richTextHtml"></web-view>
</view>
</template>
<script>
import request from "../../utils/request";
import config from '@/config'
export default {
name: "content",
data() {
return {
richTextHtml: ''
};
},
onLoad(data) {
const id = data.id;
this.getRichTextHtml(id)
},
methods:{
async getRichTextHtml(id){
try {
const res = await request({
url: '/userClient/banner/getById?id=' + id,
method: 'get'
})
const data = res.data
this.richTextHtml = data.content.replace(/(<img[^>]+src=")([^":]*?)(")/g, (match, p1, p2, p3) => {
return `${p1}${config.baseImageUrl}/${p2}${p3}`;
});
this.richTextHtml = `data:text/html;charset=utf-8,${encodeURIComponent(this.richTextHtml)}`
}catch {}
}
}
}
</script>
<style scoped lang="scss">
img{
width: 100%;
height: auto;
}
</style>