Skip to content

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

Closed
@w2819

Description

@w2819

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions