vue项目写法 reportUrl就是外部的完整链接
<template>
<div>
<iframe
style="border: none"
:width="searchTableWidth"
:height="searchTableHeight"
v-bind:src="reportUrl"
></iframe>
</div>
</template>
<script>
export default {
data() {
return {
reportUrl: '',
searchTableHeight: 0,
searchTableWidth: 0
}
},
watch: {
'$route': function () {
// 监听路由变化
this.reportUrl = this.$route.query.url
}
},
mounted() {
// console.log('28', this.$route.query.url);
this.reportUrl = this.$route.query.url
window.onresize = () => {
this.widthHeight(); // 自适应高宽度
};
this.$nextTick(() => {
this.widthHeight();
});
},
methods: {
widthHeight() {
this.searchTableHeight = window.innerHeight;
this.searchTableWidth = window.innerWidth
},
}
}
</script>
<style>
</style>