vue后端含有标签数据显示在前端

    xiaoxiao2022-07-13  156

    要想在前端显示后端含有标签的数据,则需要使用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结果如下:

    最新回复(0)