收藏
回答

uniapp开发的文章组件的前端代码在app和小程序显示不同,小程序的显示bug,老师看看是啥问题?

附上代码和截图,同样的文章源码复制在后台中,小程序显示不正常,想问下小程序的代码是否要特殊处理

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>

回答关注问题邀请回答
收藏
登录 后发表内容