-
2022-02-23 15:24:03
使用全局的store里面定义的函数
this.$store.dispatch('tagsView/delView', this.$route).then(({ visitedViews }) => {
this.$router.replace({path:"/otaconfig/otaconfig"});
})更多相关内容 -
Vue 关闭当前页、关闭当前标签tagsView
2021-07-29 09:48:14由于项目使用tagsView,关闭当前页面需要通过关闭当前标签来实现 涉及到几个点: 1. 移除VisitedView 和 CachedView 中的当前项 2. 跳转到最后一次访问的标签 主要思路:比对 路由路径 ( this.$route.path) 两种...由于项目使用tagsView,关闭当前页面需要通过关闭当前标签来实现
涉及到几个点:
1. 移除 VisitedView 和 CachedView 中的当前项
2. 跳转到最后一次访问的标签
主要思路:比对 路由路径 ( this.$route.path)
两种方式:
一、 在vue页面直接实现
closePage() var currentView = this.$store.state.tagsView.visitedViews[0] for (currentView of this.$store.state.tagsView.visitedViews) { if (currentView.path === this.$route.path) { break } } this.$store.dispatch('tagsView/delView', currentView) .then(({ visitedViews }) => { if (currentView.path === this.$route.path) { const latestView = this.$store.state.tagsView.visitedViews.slice(-1)[0] if (latestView) { this.$router.push(latestView) } else { // 如果没有其他标签则跳转到首页 if (currentView.name === '首页') { this.$router.replace({ path: '/redirect' + currentView.fullPath }) } else { this.$router.push('/') } } } })
二、在js文件中写自定义函数,在vue页面中调用
import router from '@/router/routers' // 关闭当前页 关联tagView export function closePage(store, route) { var currentView = store.state.tagsView.visitedViews[0] for (currentView of store.state.tagsView.visitedViews) { if (currentView.path === route.path) { break } } store.dispatch('tagsView/delView', currentView) .then(({ visitedViews }) => { if (currentView.path === route.path) { const latestView = store.state.tagsView.visitedViews.slice(-1)[0] if (latestView) { router.push(latestView) } else { if (currentView.name === '首页') { router.replace({ path: '/redirect' + currentView.fullPath }) } else { router.push('/') } } } }) }
-
vue-element-admin关闭当前标签页
2020-02-27 14:26:57// 调用全局挂载的方法 this.$store.dispatch('tagsView/delView', this.$route) // 返回上一步路由 this.$router.go(-1)// 调用全局挂载的方法 this.$store.dispatch('tagsView/delView', this.$route) // 返回上一步路由 this.$router.go(-1)
-
VUE-cli 标签页关闭之后缓存问题
2021-07-14 15:10:20//路由加上 { path: 'xxx', name: 'xxx', component: xxx, ...//在关闭标签标签上更换状态 if(!this.$route.meta.keepAlive){ this.$route.meta.keepAlive = true; }else{ this.$route.meta.ke...//路由加上 { path: 'xxx', name: 'xxx', component: xxx, meta: { keepAlive: false // 不需要被缓存,关闭页面在打开时刷新页面 }, } //在标签组件里的关闭标签操作上更换状态 if(!this.$route.meta.keepAlive){ this.$route.meta.keepAlive = true; }else{ this.$route.meta.keepAlive = false; } //在主页面组件跳转路由DOM设置一个判断语句缓存,一个key重置组件 <div class="article_fast" v-if="!$route.meta.keepAlive" :key="resetKey"> <keep-alive><router-view ref="pageObject" @changeLogo="changeLogo"></router-view</keep-alive> </div> <div v-else class="article_fast" > <router-view ref="pageObject" @changeLogo="changeLogo"></router-view </div> //在主页面组件路由监听里添加一个操作显示,重置组件 if(this.$route.meta.keepAlive){ ++this.resetKey; this.$route.meta.keepAlive = false; }
-
vue element 关闭当前tab 跳转到上一路由操作
2020-11-20 02:15:10方法一 this.$store.dispatch(‘delVisitedViews’, this.$route); this.$router.go(-1); 方法二 this.$store.state.tagsView.visitedViews.splice(this.$store.state.tagsView.visitedViews.findIndex(item => ... -
vue如何在用户要关闭当前网页时弹出提示的实现
2020-10-15 06:40:01主要介绍了vue如何在用户要关闭当前网页时弹出提示的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 -
vue点击关闭当前窗口
2022-05-17 13:35:54var userAgent = navigator.userAgent;...后发现谷歌和火狐对此方法有兼容问题,不能直接关闭,后只用此方法做了兼容处理,最后谷歌浏览器虽然关闭了当前页面,但是window.location.href = "about:blank"到了空白页。 -
vue关闭当前页面 跳转_如何让用户选择是否离开当前页面?
2020-11-20 00:51:05写在开头为什么要写这个文章,因为每个...不做判断,那么用户数据直接丢了梳理需求离开页面方式,被location.href,a标签,关闭浏览器或者当前tab页等...需要判断数据是否跟初始化时一致(用户有无填写表单...)用户选择... -
解决vue-router 切换tab标签关闭时缓存问题
2021-01-19 12:34:35component: resolve => require(['@/pages/product/fundPros/fundTab/fundTab.vue'], resolve), title: '基金首页', redirect: 'fundProListG/fundProListG', meta: { keepAlive: false // 不需要被缓存 }, ... -
vue关闭当前页面 跳转_vue常见面试题
2020-11-19 23:08:331.vue优点? 答:轻量级框架:只关注视图层,是一个构建数据的视图集合,大小只有几十kb; 简单易学:国人开发,中文文档,不存在语言障碍 ,易于理解和学习; 双向数据绑定:保留了angular的特点,在数据操作方面... -
Vue监听页面刷新和关闭功能
2020-12-09 21:39:26但是发现 beforeDestroy 只能监听到页面间的跳转,无法监听到页面刷新和关闭标签页。 所以还是要借助 onbeforeunload 事件。 顺便复习了一下 JavaScript 中的一些加载,卸载事件: 页面加载时只执行 onload 事件... -
Vue 关闭当前页面会到上次点击的页面
2022-01-03 15:15:46提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 Vue 关闭当前页面会到上次点击的页面 实现效果 一、相关代码 实现效果 关闭当前页面回到上次点击的页面。 一、相关代码 关闭当前 tags-view ,... -
vue关闭当前页面并返回上一路由
2021-09-13 15:51:55删除vuex里存放的store里的tabs中的相应页面this.$store.state.user.tabs.splice(this.$store.state.user.tabs.findIndex(item => item.path === this.$route.path), 1) ...返回上一页 this.$router.go(-1); -
vue关闭tab页
2022-01-14 14:43:051// 调用全局挂载的方法 that.$store.dispatch('tagsView/delView', that.$route) // 返回上一步路由 that.$router.go(-1) 2 that.$store.dispatch('tagsView/delView', that.$route).then(() =>... -
vue 项目监听浏览器窗口或标签页关闭
2021-08-20 14:59:56方案:用户登录、关闭浏览器或者标签页时向后端发送请求,用以统计登录/登出时间、登录率 解决方案 export default { name: 'APP', mounted() { this.watchTabUnload() }, methods: { watchTabUnload() { ... -
Vue返回并关闭当前页面
2021-11-04 11:10:32<p @click="back()>返回</p> back() { this.$store.state.tagsView.visitedViews.splice(this.$store.state.tagsView.visitedViews.findIndex(item => item.path === this.$route.path), 1) ... -
vue关闭当前页签,返回到上一个页面
2020-12-23 17:42:18方法一: this.$store.dispatch('delVisitedViews', this.$route); this.$router.go(-1); 方法二: ...this.$store.state.tagsView.visitedViews.splice(this.$store.state.tagsView.visitedViews.findIndex(item ... -
vue监控当前标签页是否显示状态
2020-12-19 13:31:45在vue项目开发中,页面中存在过多的定时器,轮询等操作的时候,如果浏览器标签页开的太多会出现卡顿的现象,那么如何解决此类问题呢visibilitychange可以监听当前标签页状态变化methods: {// 业务操作... -
vue-element-admin关闭当前标签页并且返回上一个标签页
2021-02-04 09:18:42// 调用全局挂载的方法,关闭当前标签页 this.$store.dispatch("tagsView/delView", this.$route); //返回上一个tab页面 返回上一步路由, this.$router.go(-1); //返回到指定路由 this.$router.push({path: '/... -
Jeecg-Boot 前端框架ant-design-vue :关闭当前tab(框架自带)
2020-08-14 09:37:23框架自带关闭当前页的方法,可参考:src/components/layouts/TabLayout.vue 1.引入 inject:['closeCurrent'], 2.调用 this.closeCurrent(); 示例: -
vue实现多个tab标签页的切换与关闭
2022-03-06 23:22:171.实现效果 2.实现原理 vuex,实现对当前激活项,当前tab列表,当前tab的translateX,当前缓存...当点击tab标签页的时候,获取相应的激活项,动态的实现左侧菜单栏的选中状态,用watch监听,updateActiveName和upda -
vue 刷新当前页面或者跳转页面时候刷新
2020-12-19 16:40:11为什么会有这篇文章1 用vue-router 重新路由的时候到当前页面的时候是不进行刷新的2 采用window.reload() 或者router.go(0) hisory.go(0) 刷新的时候整个浏览器进行刷新加载, 但是页面闪烁, 体验不好解决办法方式... -
若依 vue 基于前后端分离系统实现点击按钮,关闭当前页面及动态导航标签,刷新当前页面
2021-12-02 23:01:38需求: 关闭当前页面,跳转到指定的页面 按钮绑定 goBack() 事件 // 返回 goBack(){ // 关闭当前页面 // this.$store.dispatch('tagsView/delView', this.$route); // 跳转目标页面 // this.$router.... -
vue点击菜单实现多标签页tab,打开关闭多个页面
2022-01-20 14:09:55vue菜单多标签tab,打开关闭多个页面 -
vue-element-admin关闭当前标签页并返回上一级
2021-04-08 15:23:00goBack(){ this.$store.dispatch("tagsView/delView", this.$route); this.$router.go(-1); } -
如何机智判断页面是刷新还是关闭,背景:vue项目,需求:关闭页面,下次直接跳到登陆页
2021-01-12 05:17:58最近项目有这么个需求:要在关闭当前系统的窗口的时候,退出登录,因为如果不退出登录可能存在安全风险,其实我想说,电脑没事别借给别人活着离开工位记得一定要锁屏,其实我们设置了cookie失效时间的,过了一段时间... -
Vue完成标签页组件
2021-06-18 16:33:57Vuejs_actual_tabs.vue :标签页切换头 Vuejs_actual_pane.vue: 标签页显示内容 style.css moduleApply.vue : 使用页面 Vuejs_actual_tabs.vue <template> <div class="tabs"> <div class="tabs-...
收藏数
9,716
精华内容
3,886