zoukankan      html  css  js  c++  java
  • 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 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"))
    }

  • 相关阅读:
    关于自链接的视图的更新
    JavaScript局部变量与全局变量2
    减少IDE中的新建项
    whitespace对select无效
    学习摘录21
    让我记得写文档的设置
    本地连接不见了
    jquery 学习笔记
    jquery用load引入页面
    android笔记
  • 原文地址:https://www.cnblogs.com/www3j/p/13093393.html
Copyright © 2011-2022 走看看