举个例子
<div class="title">图文详情</div>
<div class="datails_info" id="datails_info">
//此处是要展示html代码的
</div>
</div>
//获取到datails_info vm.goods.goods_content是后台给的html代码
document.getElementById("datails_info").innerHTML=htmlDecode(vm.goods.goods_content);
js工具类
var htmlDecode = function(htm) {
var temp = document.createElement("div");
temp.innerHTML = htm;
var output = temp.innerText || temp.textContent;
temp = null;
return output;
}
就像上面就OK 了
第二种写法(Vue)
<div class="fwb_box" v-html="content"></div>
vm.content = htmlDecode(result.content);
网友评论