vue 获取页面详情后 切换页面时 如何监听用户是否修改过信息
可以用 beforeRouteLeave 和 updated 来判断。export default {
name: 'supplier',
components:{cmtWrap,cmtContent},
props: [],
beforeRouteLeave (to, from, next) {//离开当前页
if(this.updateCount > ){ //更新次数大于1 说明用户修改过当前页数据 因为获取详情时会更新一次
if(from.path.includes('nowPath')){
this.$confirm('即将离开当前页,请确定是否保存当前数据?', '离开当前页', {
confirmButtonText: '保存',
cancelButtonText: '不保存',
type: 'warning'
}).then(() => {
//...todo 这里调接口 保存数据
next()
}).catch(() => {next()});
}else{next()}
}else{
next()
}
},
updated:function () {
this.updateCount = this.updateCount +
},
data() {
return {
updateCount:,//判断用户是否更新当前数据
}
},
computed:{},
watch:{},
mounted:function () {
this.getInitData()
},
methods: {
getInitData:function(){
//...todo 页面进来,先获取默认数据 }
},
}
vue 获取页面详情后 切换页面时 如何监听用户是否修改过信息的更多相关文章
- js中对arry数组的各种操作小结 瀑布流AJAX无刷新加载数据列表--当页面滚动到Id时再继续加载数据 web前端url传递值 js加密解密 HTML中让表单input等文本框为只读不可编辑的方法 js监听用户的键盘敲击事件,兼容各大主流浏览器 HTML特殊字符
js中对arry数组的各种操作小结 最近工作比较轻松,于是就花时间从头到尾的对js进行了详细的学习和复习,在看书的过程中,发现自己平时在做项目的过程中有很多地方想得不过全面,写的不够合理,所以说啊 ...
- SpringMVC拦截器实现:当用户访问网站资源时,监听session是否过期
SpringMVC拦截器实现:当用户访问网站资源时,监听session是否过期 一.拦截器配置 <mvc:interceptors> <mvc:interceptor> < ...
- EditText设置文字改变时的监听
textWatcher = new TextChangeWatcher(); etQuerryInfo.addTextChangedListener(textWatcher); /** * 文字改变类 ...
- 【winform】基于UserControl实现webBrower组件时html页面元素加载及onclick事件监听实现
[背景]基于System.Windows.Forms.UserControl实现的webBrower组件在html内使用window.external调用winform事件失败. [解决思路]借助wi ...
- iframe中,页面转换后回到页面的顶部
看到网上有这样描述的: 现在A页面内分为上下两个部分,上部分是top,下部分分左右,左是treeview右边是iframe,iframe内嵌一个B页面,B页面的内容实质上是个月刊,可以理解为杂志,里面 ...
- 后台自动运行,定期记录定位数据(Hbuilder监听 app由前台切换到后台、切换运行环境的 监听方法)
http://ask.dcloud.net.cn/question/28090 https://blog.csdn.net/qq_37508970/article/details/86649703 各 ...
- vue --》路由query 编程式导航传值与监听
1.首先在一个页面设置一个按钮,用于路由跳转 <template> <div> <button @click="handleToRouter"> ...
- NGUI无法按住鼠标按住时无法监听OnHover事件
UICamera.cs 修改前: if ((!isPressed) && highlightChanged) { currentScheme = ControlScheme.Mouse ...
- 20、解决Vue使用bus兄弟组件间传值,第一次监听不到数据
1.新建bus.js文件: import Vue from 'vue' export default new Vue; 2.在需要通信组件A,B中引入bus: A组件: import Bus from ...
随机推荐
- Foxmail6.5 ERR LOGIN FAIL 重新输入口令
这几天 Foxmail 6.5 收邮件不正常,一直报告ERR LOGIN FAIL,要求重新输入口令. 但输入正确的口令也无法收邮件. 反复折腾,最后发现如下设置即可: 邮箱账户设置 --> 邮 ...
- gps 经纬度 转换实际距离
<!doctype html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...
- [Swift]LeetCode4. 两个排序数组的中位数 | Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...
- [Swift]LeetCode641. 设计循环双端队列 | Design Circular Deque
Design your implementation of the circular double-ended queue (deque). Your implementation should su ...
- [Swift]LeetCode924.尽量减少恶意软件的传播 | Minimize Malware Spread
In a network of nodes, each node i is directly connected to another node j if and only if graph[i][j ...
- [Swift]LeetCode992. K 个不同整数的子数组 | Subarrays with K Different Integers
Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A g ...
- C/C++数据在内存中的存储方式
目录 1 内存地址 2 内存空间 在学习C/C++编程语言时,免不了和内存打交道,在计算机中,我们存储有电影,文档,音乐等数据,这些数据在内存中是以什么形式存储的呢?下面做一下简单介绍. 本文是学 ...
- spring boot -spring data-redis
//添加依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId> ...
- Python、pip和scrapy的安装——Python爬虫学习笔记1
Python作为爬虫语言非常受欢迎,近期项目需要,很是学习了一番Python,在此记录学习过程:首先因为是初学,而且当时要求很快速的出demo,所以首先想到的是框架,一番查找选用了Python界大名鼎 ...
- .NET Core实战项目之CMS 第二章 入门篇-快速入门ASP.NET Core看这篇就够了
作者:依乐祝 原文链接:https://www.cnblogs.com/yilezhu/p/9985451.html 本来这篇只是想简单介绍下ASP.NET Core MVC项目的(毕竟要照顾到很多新 ...