fix:修改页面刷新全局样式丢失问题

feature/comment-0620-ch
ch 2 years ago
parent 3d61ca3c1e
commit 3739301d83

@ -1,3 +1,10 @@
<!--
* @Author: ch
* @Date: 2022-05-27 17:44:36
* @LastEditors: ch
* @LastEditTime: 2022-06-29 21:37:10
* @Description: file content
-->
<!DOCTYPE html>
<html lang="zh-CN">
@ -14,7 +21,7 @@
<link rel="stylesheet" href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css" />
</head>
<body>
<body class="page">
<noscript>
<strong>Please enable JavaScript to continue.</strong>
</noscript>

@ -2,7 +2,7 @@
* @Author: ch
* @Date: 2022-03-18 11:11:05
* @LastEditors: ch
* @LastEditTime: 2022-03-18 11:11:05
* @LastEditTime: 2022-06-29 21:53:26
* @Description: file content
*/
import {RouterMount,createRouter} from 'uni-simple-router';
@ -13,6 +13,10 @@ const router = createRouter({
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
// 兼容页面刷新body样式丢失问题
if (document.body) {
document.body.setAttribute('class', `uni-body ${to.path.replace('/', '').replace(/\//g, '-')}`)
}
next();
});
// 全局路由后置守卫

Loading…
Cancel
Save