Skip to content

Commit

Permalink
feat(update api): add history list to global api getCurrentPages
Browse files Browse the repository at this point in the history
  • Loading branch information
JingyuanZhang committed Apr 23, 2019
1 parent dabce11 commit 4667930
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions packages/mars-build/src/h5/template/router.js
Expand Up @@ -24,11 +24,6 @@ router.beforeEach(function (to, from, next) {
to.query._ = guid();
}

Vue.prototype.currentRoute = [{
route: to.path.replace(/^\//, ''),
uri: to.path.replace(/^\//, ''),
options: to.query
}];
let toPath = decodeURI(to.fullPath); // 兼容 vue-router 浏览器前进/返回时的 decodeURI操作
let fromPath = decodeURI(from.fullPath);
const browserHistoryArr = browserHistory.list;
Expand Down Expand Up @@ -77,7 +72,10 @@ router.beforeEach(function (to, from, next) {
|| -1 === browserHistoryIndex
|| browserHistoryIndex !== browserHistoryLength - 1) {
browserHistoryArr.push({
path: toPath
path: toPath,
route: to.path.replace(/^\//, ''),
uri: to.path.replace(/^\//, ''),
options: to.query
});
}
}
Expand All @@ -86,6 +84,7 @@ router.beforeEach(function (to, from, next) {
// browserHistoryArr = [];
// browserHistoryArr.push({path: to.fullPath});
// }
Vue.prototype.currentRoute = browserHistoryArr;
browserHistory.set(browserHistoryArr);
router.app.$nextTick(() => {
const browserHistoryArr = browserHistory.list;
Expand Down

0 comments on commit 4667930

Please sign in to comment.