Last active
June 27, 2019 11:29
-
-
Save xsthunder/fc1b790ea02f51888ece4012decd9a9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in main.js | |
import Router from 'vue-Router' | |
vue.use(Router) | |
const originalPush = router.push | |
router.push = function(obj, ...params){ | |
const current = this.history.current | |
// console.log(this, current) | |
const currentPath = current.path | |
const prefix = "/simed/" | |
if(obj instanceof Object && obj['doNotHack'] !== true){ | |
let toPath = obj['path'] | |
if(toPath && currentPath.indexOf(prefix)==0 && toPath.indexOf(prefix) == -1){ | |
toPath = `/simed${toPath}` | |
obj['path'] = toPath | |
} | |
} | |
originalPush.call(this, obj, ...params) // see https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Function/call | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment