在 Vue 中使用 window.open(href.href, '_blank') 打开一个新窗口时,如果浏览器的弹出窗口阻止器(pop-up blocker)处于活动状态,可能会阻止弹出新窗口。这可能是由于浏览器的安全设置或用户的浏览器扩展程序造成的。
在需要接口返回信息后进行跳转的逻辑处理中,如果响应时间过长会导致浏览器将弹出框默认为垃圾网站, 但当前页面不牵扯新开页签的情况,浏览器不会进行限制跳转,此时若无法优化接口响应时间, 那就先进行设置一个页面配置路由,先在此页面进行请求接口, 响应成功后在此页面利用route.push进行跳转
<template> <div class="box"> </div> </template> <script> import { include } from '@/utils/api/screen' export default { data () { return { } }, mounted() { include({id:this.$route.query.id}).then(res => { this.$router.push({ path: '/list', query: { id: this.$route.query.id } }) }).catch( err => { }) } } </script> <style lang="less" scoped> </style>
此代码为示例, 需在路由中进行配置 这样就不会触发阻拦弹框