1,使用iframe渲染html字符串
<iframe id="iframeBox" width="100%" height="100%" scrolling="auto" @load="adjustIframe" frameborder="0" />
2,拿到后端返回的html字符串
//设置iframe高度
adjustIframe() {
var ifm = document.getElementById("iframeBox");
ifm.height = (document.documentElement.clientHeight - 100) + 'px';
},
viewDetail(row) {
this.dialogVisible = true
this.$nextTick(() => {
const iframe = document.getElementById('iframeBox')
const iframedoc = iframe.contentDocument || iframe.contentWindow.document
// iframe.height = document.documentElement.clientHeight;
iframedoc.write(row.html_content)
})
},