feat: 添加滚动行为和优化路由插件注册顺序
This commit is contained in:
@ -6,21 +6,22 @@ const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes,
|
||||
strict: true,
|
||||
scrollBehavior: () => ({ left: 0, top: 0 }),
|
||||
});
|
||||
if (import.meta.hot) handleHotUpdate(router);
|
||||
if ($__DEV__) Object.assign(window, { router });
|
||||
router.onError((error) => {
|
||||
console.debug('🚨 [router error]: ', error);
|
||||
});
|
||||
|
||||
if (import.meta.hot) handleHotUpdate(router);
|
||||
if ($__DEV__) Object.assign(window, { router });
|
||||
|
||||
function setupRouter(app: import('vue').App) {
|
||||
app
|
||||
.use(DataLoaderPlugin, { router }) // Register the plugin before the router
|
||||
.use(router); // adding the router will trigger the initial navigation
|
||||
// Register the plugin before the router
|
||||
.use(DataLoaderPlugin, { router })
|
||||
// adding the router will trigger the initial navigation
|
||||
.use(router);
|
||||
}
|
||||
export { router, setupRouter };
|
||||
|
||||
// ========================================================================
|
||||
// =========================== Router Guards ==============================
|
||||
// ========================================================================
|
||||
|
Reference in New Issue
Block a user