0ba95efe by simon

1.切换语言时切换标题

1 parent 5da175cf
......@@ -80,7 +80,7 @@ let vueInstance = new Vue({
// queryConfigData: localStorage.getItem("queryConfig") || null, // 2.放localStorage
}
}).$mount('#app');
// window.vueInstance = vueInstance; // 实在不满足需要,可以把vue实例挂载到windows上
window.vueInstance = vueInstance; // 实在不满足需要,可以把vue实例挂载到windows上
/**
* 初始化请求配置
......
......@@ -313,10 +313,12 @@ const router = new Router({
});
router.beforeEach((to, from, next) => {
function setTitleByRouter(to){
let langStr = localStorage.getItem("lang") || 'tc';
let lang;
// switch
let defaultTitle = "中国平安人寿(香港)";
switch (langStr) {
// 简体
......@@ -356,6 +358,11 @@ router.beforeEach((to, from, next) => {
}
document.title = title;
}
}
router.beforeEach((to, from, next) => {
setTitleByRouter(to);
// const scrollTopList = [
// "newsList", "newsDetail", "protocol", "privacy", "terms", "paymentType", "reservation"
// ]
......@@ -365,3 +372,13 @@ router.beforeEach((to, from, next) => {
});
export default router;
function initEvt() {
window.vueInstance.eventBus.$on("langChange", () => {
setTitleByRouter(window.vueInstance._route)
});
}
setTimeout(() => {
initEvt();
}, 0);
\ No newline at end of file
......