附上代码和截图,同样的文章源码复制在后台中,小程序显示不正常,想问下小程序的代码是否要特殊处理
app:
小程序:
<template>
<view class="content">
<view class="productInfo" v-html="content"></view>
</view>
</template>
<script>
export default {
data() {
return {
content:''
}
},
onLoad(t){
let str = decodeURIComponent(t.html).replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi,function(match,capture){
var newStr='<img src="https://www.caihongplus.com/'+capture+'" alt="" width="100%" />';
return newStr;
});
this.content = str
console.log(decodeURIComponent(t.html))
// this.getInfo(id)
},
methods: {
// async getInfo(){
// let res = await this.$util.post('')
// var newContent= res.data.content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi,function(match,capture){
// var newStr='<img src="https://www.caihongplus.com/'+capture+'" alt="" width="100%" />';
// return newStr;
// });
// console.log(newContent)
// this.content = newContent
// },
}
}
</script>
<style>
.content{padding:30upx;}
</style>
