vue打开外部页面_vue项目中嵌套外部网页
主要有两种方法:
一、通过接口请求,然后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页面里某个标签
var i = document.getElementById('iframename');
i.onload = function(){
console.log(i.contentWindow.document)
console.log(i.contentWindow.document.getElementsByClassName("login-user-input"))
}
AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。
更多推荐


所有评论(0)