是否可以在不使用的情况下重写浏览器的历史记录history.pushState
?
我有一个带有路由器的骨干应用程序,看起来像这样:
routes: {
'posts': 'posts',
'modal': 'modal'
},
'before': function (args) {
//check if logged in
//do some various other setup tasks
//maybe delete modal routes from the history?
//forward to route
args.next()
},
'posts': function () {
//make and show posts
},
'modal': function (params) {
//edit user email preferences OR
//create a new post OR
//do various other crud operations
}
每当触发模式路由时,我都想防止将哈希写入浏览器的历史状态。原因是,用户在回溯历史时不应该重新打开模式。
我查看了主干源代码,但没有看到任何简单的内容history = []
。
有没有办法在没有推送状态的情况下做到这一点?