主要有兩種方法:
一、通過接口請求,然后v-html渲染,這種方法試驗之后發現不行,v-html不會渲染內部頁面
二、iframe的方式(解決引入成功之后獲取不到引入的標簽問題及跨域問題)
需要嵌套的網頁地址為:http://10.108.230.74:8080/smartbi/vision/openresource.jsp
config.js文件中設置代理:
dev: {
env: require('./dev.env'),
host: '0.0.0.0',
port: '8080',
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/jsp': {
target: 'http://10.108.230.74:8080', // 接口地址
changeOrigin: true, // 是否跨域
pathRewrite: { // 轉發
'^/jsp': ''
},
secure: false,
headers: {
Referer: 'https://10.108.230.74:8080'
}
},
},
備注:代理里面https的url才需要加headers的參數
在頁面引入:
<iframe src="jsp/smartbi/vision/openresource.jsp" width="100%" height="800" frameborder="0" scrolling="auto" id="iframename" name="iframename"></iframe>
獲取iframe頁面里某個標簽
var i = document.getElementById('iframename');
i.onload = function(){
console.log(i.contentWindow.document)
console.log(i.contentWindow.document.getElementsByClassName("login-user-input"))
}