物理回退/回退

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