<template>
<div style="height:100%;overflow: auto;" v-loading="loading">
<iframe ref="iframe" :src="https://juejin.cn/post/src" width="100%" height="100%" frameborder="0"></iframe>
</div>
</template>
<script>
export default {
data() {
return {
src: 'https://www.baidu.com',
loading: true,
};
},
created() {
},
mounted() {
const { iframe } = this.$refs;
// IE和非IE浏览器,监听iframe加载事件不一样,需要兼容
const that = this;
if (iframe.attachEvent) {
// IE
iframe.attachEvent('onload', () => {
that.stateChange();
});
} else {
// 非IE
iframe.onload = function () {
that.stateChange();
};
}
},
methods: {
stateChange() {
this.loading = false;
},
},
};
</script>
<style scoped></style>
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END