此处应注意:iframe的src和正式环境的域名应该是相同的,顶级域名相同也可,不然会出现跨域问题
src:https://abc.baidu.com
浏览器环境:https://def.baidu.com
<template>
<div>
<iframe
id="iframe"
ref="iframe"
:src="grafana_api"
width="100%"
:height="mainHeight"
frameborder="no"
>
</iframe>
</div>
</template>
<script>
export default {
data(){
return{
mainHeight: '',
grafana_api: '',
}
},
mounted(){
window.screenHeight = document.body.clientHeight;
this.mainHeight = window.screenHeight - 52 + 'px';//高度自适应
this.grafana_api = 'https://abc.baidu.com'
},
}
</script>