vue项目通过url链接引入其他系统页面

1.正常配置菜单,在vue页面使用iframe进行嵌套加载其它系统的页面,已加载百度为例

<template>
  <div id="app">
      <iframe
         style="border:none"
         :width="searchTableWidth"
         :height="searchTableHeight"
         v-bind:src="reportUrl"
       ></iframe>
  </div>
</template>
<script>
import Vue from 'vue'
export default {
  methods: {
    widthHeight() {
      this.searchTableHeight = window.innerHeight -180;
      this.searchTableWidth = window.innerWidth - 230
    },
  },
  data() {
    return {
      reportUrl: 'https://www.baidu.com/',
      searchTableHeight: 0,
      searchTableWidth: 0
    }
  },
   mounted() {
    window.onresize = () => {
      this.widthHeight(); // 自适应高宽度
    };
    this.$nextTick(function () {
      this.widthHeight();
    });
  },
  created() {
    // 从路由里动态获取 url地址   具体地址看libs下util.js里的 backendMenuToRoute  方法 
    this.reportUrl = 'https://www.baidu.com/'
  },
  watch: {
    '$route': function () {
      // 监听路由变化
      this.reportUrl =  'https://www.baidu.com/'
    }
  }
}
</script>

效果图:

2.加载引入系统可能会出现拦截,xxx 拒绝了我们的连接请求。前端页面Refused to display 'xxx' in a frame because it set 'X-Frame-Options' to 'sameorigin',对于这个问题我们需要在引入的项目中进行拦截处理,引入项目中response.addHeader("x-frame-options","SAMEORIGIN")需要改写为response.addHeader("x-frame-options","ALLOW-FROM http://127.0.0.1:项目端口/");对访问方式进行允许iframe不同域名之间进行调动

3.引入项目的后台拦截代码

@Configuration
public class MvcConfig implements WebMvcConfigurer {
   //配置日志
    private static final Logger logger= LoggerFactory.getLogger(MvcConfig.class);
    
    @Autowired
    SystemConfig systemConfig;
   
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new HandlerInterceptor() {
            @Override
            public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
                //设置日志级别
                //logger.debug("前置方法被执行");
                return true;
            }
 
            @Override
            public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
                //logger.info("后置方法被执行");
                //System.out.println(systemConfig.getMqiUrl());
                if(null == modelAndView){
                    return;
                }
                response.addHeader("x-frame-options","ALLOW-FROM http://127.0.0.1:8004/");

                modelAndView.getModelMap().addAttribute("arcgisserviceUrl", systemConfig.getArcgisserviceUrl());
            }
 
            @Override
            public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
                //logger.debug("最终方法被执行");
            }
        });
    }
}

  • 13
    点赞
  • 53
    收藏
    觉得还不错? 一键收藏
  • 15
    评论
Uniapp是一种多端统一开发框架,其tabbar页面是一种常用的页面类型,可以方便地进行快速切换和导航。给tabbar页面引入链接,可以在页面中添加跳转链接,实现更灵活的页面跳转。 要在Uniapp tabbar页面引入链接,需要按照以下步骤操作: 1. 在uni文件夹中创建一个新的页面或者复制一个已有页面,如home.vue或者mine.vue。 2. 在新页面中添加跳转链接。可以使用`<navigator>`标签来创建一个超链接,例如: ```html <navigator url="/pages/buy/buy"></navigator> ``` 通过设置`url`属性来指定跳转页面的路径。 3. 在tabbar页面的`pages`属性中添加新页面的路径。例如: ```js "pages": [ { "path": "pages/home/home", "name": "home", "style": {} }, { "path": "pages/mine/mine", "name": "mine", "style": {} }, { "path": "pages/buy/buy", "name": "buy", "style": {} } ] ``` 在`pages`数组中添加新页面的路径,使其可以在tabbar中显示并进行页面跳转。 4. 在tabbar组件中添加对新页面的引用。例如: ```html <tabbar> <tabbar-item icon="home" name="home">首页</tabbar-item> <tabbar-item icon="account" name="mine">我的</tabbar-item> <tabbar-item icon="shopping-cart" name="buy">购买</tabbar-item> </tabbar> ``` 添加`<tabbar-item>`组件并设置相应的图标和名称,使其与新页面的引用相对应。 通过以上步骤,就可以在Uniapp tabbar页面中成功地引入跳转链接,实现更加灵活的页面跳转和导航功能。
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值