Process images in rich text

1. The picture is displayed proportionally without height: auto; the picture will be stretched

  result = result.replace(regex, `<img style="max-width: 100%;display:block;margin-left:0;height:auto;"`)
    <div class="text" v-html="content">
  data() {
    
    
    return {
    
    
      content: '',
    }
  },
 getaddress() {
    
    
      this.$api
        .address({
    
    })
        .then((res) => {
    
    
          this.config_list = res.data.config_list
          let result = this.config_list.company_honor
          const regex = new RegExp('<img', 'gi')
          result = result.replace(regex, `<img style="max-width: 100%;display:block;margin-left:0;"`)
          this.content = result
          console.log(this.config_list)
          //  console.log(res.data);
        })
        .catch((err) => {
    
    
          console.log(err)
        })
    },

Guess you like

Origin blog.csdn.net/qq_45894929/article/details/109495080