Skip to content

Commit

Permalink
Merge pull request #344 from ambit-tsai/master
Browse files Browse the repository at this point in the history
提高getLocation函数的ie8兼容性
  • Loading branch information
RubyLouvre authored Oct 4, 2018
2 parents 8b6aa3a + 664dcd7 commit 04adba1
Showing 1 changed file with 8 additions and 3 deletions.
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
};
};

0 comments on commit 04adba1

Please sign in to comment.