要想在前端显示后端含有标签的数据,则需要使用v-html

后端数据https://www.easy-mock.com/mock/5ce57090f2fc446b5d8ffe18/blog/html
在这里插入图片描述
前端显示
在这里插入图片描述
完整代码如下:(主要看加粗的代码)
< template>
< div class=“show-examples”>
< div v-html=“blogData.content”>{{blogData.content}}< /div>
< /div>
< /template>

< script >
import axios from ‘axios’
export default{
name:‘show-examples’,
data(){
return{
blogData:’ ',
}
},
mounted(){
this.getData();
},
methods:{
getData(){
axios.get(‘https://www.easy-mock.com/mock/5ce57090f2fc446b5d8ffe18/blog/html’) .then((res)=>{
this.blogData=res.data.data;
})
}
}
}
< /script>
< style >< /style>

不使用v-html结果如下:
在这里插入图片描述

Logo

前往低代码交流专区

更多推荐