iframeLoad() {
this.loading = true;
const iframe = this.$refs.iframe;
// 兼容处理
if (iframe.attachEvent) {
// IE
iframe.attachEvent("onload", () => {
this.loading = false;
});
} else {
// 非IE
iframe.onload = () => {
this.loading = false;
};
}
},
<div
v-loading="loading"
element-loading-text="拼命加载中"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)"
>
<iframe :src="iframeSrc" width="100%" height="100%" frameborder="0" id="iframe" ref="iframe"></iframe>
</div>
v-loading要加在iframe外面,通过onload事件判断iframe是否加载完成