vue.js - 当用户未授权时,在登录页面之前看到内部面板的闪烁
问题描述
每当我进入我的页面时,如果用户登录,我都会重定向到内部面板。我在这里检查
router.beforeEach((to, from, next) => {
if (to.matched.some(record => record.meta.authRequired)) {
const { authState } = useAuthStore(router.pinia);
if (authState == false) {
return next('/login')
}
}
next();
});
如果用户未登录,我会看到 0.5 秒的Panel
组件闪烁,有没有办法避免这种情况?
const routes = [
{
path: "/",
name: "Base",
component: Base,
redirect: "/",
meta: {
authRequired: true,
},
children: [
{
path: "",
name: "Panel",
component: Panel,
解决方案
推荐阅读
- woocommerce - Woocommerce-Notice-Wrapper / Woocmmerce-info
- python - NameError:未定义名称“BinanceAPIException”
- ios - 签名身份和配置文件混淆 Gluon Mobile
- python - Cantera (Python 3.8) 安装后在 PyCharm 中不可用包
- python - 我试图为我的石头剪刀布python游戏制作一个评分系统。我希望它是最好的 2 out of 3
- aem - AEM 跳过:部署到调度程序原因:没有调度程序配置包
- reactjs - 空投智能合约组件时间不倒计时?
- python - Python Selenium 无法单击元素:无法在“窗口”上执行“getComputedStyle”
- spring - 如何创建一个 mongodb 到实体转换器?
- css - 更改id时反应导航栏组件css不更新