Skip to content
Merged
Changes from all commits
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
11 changes: 8 additions & 3 deletions packages/router/history.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@ import {
export var modeObject = {}
//伪造一个Location对象
function getLocation(source) {
return {
...source.location,
const location = {
getPath() {
return modeObject.value === "hash" ? this.hash.slice(1) : this.pathname
},
state: source.history.state,
key: (source.history.state && source.history.state.key) || "initial"
};
for (const key in source.location) {
if (Object.prototype.hasOwnProperty.call(source.location, key)) {
location[key] = source.location[key];
}
}
return location;
}

//伪造一个History对象
Expand Down Expand Up @@ -175,4 +180,4 @@ export {
navigate,
createHistory,
createMemorySource
};
};