首页 > 其他 > 详细

物理回退/回退

时间:2020-07-06 12:54:39      阅读:50      评论:0      收藏:0      [点我收藏+]
import { Dialog } from ‘vant‘;
Vue.use(Dialog);

//物理回退
backButton () { // 有选择的增加这个提示语

Dialog.confirm({

message: ‘是否放弃新建类目 ‘

}).then(() => {

this.$router.push(‘/productDescription‘);

}).catch(() => {

});


},

goBack () {

Dialog.confirm({

message: ‘是否放弃新建类目 ‘

}).then(() => {

this.$router.push(‘/productDescription‘);

}).catch(() => {

});


},

mounted () {

//监听返回键
if (window.history && window.history.pushState) {
history.pushState(null, null, document.URL);
window.addEventListener(‘popstate‘, this.backButton, false);//false阻止默认事件
}

},

destroyed () {

window.removeEventListener(‘popstate‘, this.backButton, false);//false阻止默认事件

},

物理回退/回退

原文:https://www.cnblogs.com/emmawang1988/p/13253768.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!