Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the function abort() to prevent history.back() more than twice,then history.back() can't go last page. #1031

Closed
w2819 opened this issue Dec 21, 2016 · 5 comments
Labels

Comments

@w2819
Copy link

w2819 commented Dec 21, 2016

version: "vue-router": "^0.7.13","vue": "^1.0.28"

browser history: index -> list-> detail->buy

buy.vue:
<a @click="back">back</a>
back:()=>history.back()

I confirm user when click the back button
i do this in router because i want prevent the browser's back button too
router.beforeEach(({to, from, next, abort}) => {
let confirm = window.confirm('are you sure to leave this page?')
if(confirm){
abort()
}else{
next()
}
})

I click the back button first time, and abort,do it again.
then i click it the third time,do next,it go index but not detail...

@fnlctrl
Copy link
Member

fnlctrl commented Dec 21, 2016

Hi, please make sure to follow the Issue Reporting Guidelines before opening an issue. Thanks!

@fnlctrl fnlctrl closed this as completed Dec 21, 2016
@fnlctrl
Copy link
Member

fnlctrl commented Dec 21, 2016

Seems to be the same issue of which was addressed by #894. Though it's not fixed for 0.7

@fnlctrl fnlctrl reopened this Dec 21, 2016
@fnlctrl fnlctrl added the 1.x label Dec 21, 2016
@w2819
Copy link
Author

w2819 commented Dec 21, 2016

thank you , can you fix it?

@w2819
Copy link
Author

w2819 commented Dec 23, 2016

is there anybody to fix this?

@Jialufeng
Copy link

Jialufeng commented Dec 7, 2017

new Vue({
    el: '#vueApp',
    data: {
        debug: true,
        users: [],
        xhr_request:[]
    },
    beforeDestroy:function() {
        for (var i = 0; i < this.xhr_request.length; i++) {
            this.xhr_request.shift().abort();
        }
    },
    methods: {
        loadUsers: function() {
            this.$http.get('https://jsonplaceholder.typicode.com/users', 
                 function(data, status, request) {
                     if(status == 200) { 
                          this.users = data;
                 }
            },
             { beforeSend: function(xhr) { 
                     this.xhr_request.push(xhr);
           }
      });
            console.log(this.$http());
}
}
});

当还有在执行的ajax时候,取消ajax

@posva posva closed this as completed Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants