• 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"))
    }

  • 相关阅读:
    VS2010之– Web Development(四)-将WebApplication打包发布到IIS
    .NET中TextBox控件设置ReadOnly=true后台取不到值三种解决方法
    jQuery 二级联动
    ajax实现无刷新两级联动DropDownList
    CheckStyle
    《Thinking in Java》学习笔记(三)
    Java垃圾回收机制[转]
    《Thinking in Java》学习笔记(二)
    MySQL操作的一些优化
    《Thinking in Java》学习笔记(一)
  • 原文地址:https://www.cnblogs.com/www3j/p/13093393.html
Copyright © 2020-2023  润新知