Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add the replace attribute in location for hooking in beforeEach
  • Loading branch information
wanyaxing committed Nov 26, 2017
commit 4bb9331d5fb4f37ce339b18a2a75f923b03b9b5c
6 changes: 6 additions & 0 deletions src/history/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ export class HashHistory extends History {

replace (location: RawLocation, onComplete?: Function, onAbort?: Function) {
const { current: fromRoute } = this
if (typeof location === 'string'){
location = {path:location}
}
if (typeof location === 'object' && !location.replace){
location.replace = 1
}
this.transitionTo(location, route => {
replaceHash(route.fullPath)
handleScroll(this.router, route, fromRoute, false)
Expand Down
6 changes: 6 additions & 0 deletions src/history/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export class HTML5History extends History {

replace (location: RawLocation, onComplete?: Function, onAbort?: Function) {
const { current: fromRoute } = this
if (typeof location === 'string'){
location = {path:location}
}
if (typeof location === 'object' && !location.replace){
location.replace = 1
}
this.transitionTo(location, route => {
replaceState(cleanPath(this.base + route.fullPath))
handleScroll(this.router, route, fromRoute, false)
Expand Down
1 change: 1 addition & 0 deletions src/util/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function createRoute (
meta: (record && record.meta) || {},
path: location.path || '/',
hash: location.hash || '',
replace: location.replace || 0,
query,
params: location.params || {},
fullPath: getFullPath(location, stringifyQuery),
Expand Down