whychw
2020-04-16 8755bc88034dc3c8a8ea7ca06989f5babf0562db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './assets/css/common.css'
import './assets/iconfont/iconfont.css'
 
Vue.config.productionTip = false
 
 
const setHtmlFontSize = () => {
    const htmlDom = document.getElementsByTagName('html')[0];
    let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
    if (htmlWidth >= 750) {
        htmlWidth = 750;
    }
    if (htmlWidth <= 320) {
        htmlWidth = 320;
    }
    htmlDom.style.fontSize = `${htmlWidth / 7.5}px`;
};
 
// 进入路由前
router.beforeEach((to, from, next) => {
    // 修改主导航的激活状态
    store.dispatch('changeNavName', to.name);
    // 修改面包屑导航内容
    store.dispatch('changeCrumb', to.meta.crumb);
    next();
});
 
window.onresize = setHtmlFontSize;
 
setHtmlFontSize();
 
new Vue({
    router,
    store,
    render: h => h(App),
}).$mount('#app')