Skip to content

Commit d51fe03

Browse files
committed
fix: 修复路由守卫中beforeRouter和afterRouter的定义位置
1 parent 3e7abc0 commit d51fe03

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/vue2/src/init.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,8 @@ const init = (appConfig, platformConfig, routes, metaData) => {
184184
*/
185185
const router = createRouter(baseRoutes);
186186

187-
const beforeRouter = window.beforeRouter || Vue.prototype.beforeRouter;
188-
const afterRouter = window.afterRouter || Vue.prototype.afterRouter;
189-
190187
const getAuthGuard = (params) => async (to, from, next) => {
188+
const beforeRouter = window.beforeRouter || Vue.prototype.beforeRouter;
191189
try {
192190
if (typeof beforeRouter === 'function') {
193191
await beforeRouter({
@@ -230,6 +228,8 @@ const init = (appConfig, platformConfig, routes, metaData) => {
230228
* 执行‘端事件---页面进入前’
231229
*/
232230
router.afterEach(async (to, from) => {
231+
const afterRouter = window.afterRouter || Vue.prototype.afterRouter;
232+
233233
try {
234234
if (typeof afterRouter === 'function') {
235235
await afterRouter(to, from);

0 commit comments

Comments
 (0)