This article mainly introduces the issue of how to add a dynamic browser header title in the Vue project. It has a certain reference value. Now I share it with you. Friends in need can refer to it
Vue project to add a dynamic browser header title
##1. Implementation ideasrouter.beforeEach((to, from, next) => {} Inside
const browserHeaderTitle = to.name
SET_BROWSERHEADERTITLE: (state, action) => { state.browserHeaderTitle = action.browserHeaderTitle } store.commit('SET_BROWSERHEADERTITLE', { browserHeaderTitle: browserHeaderTitle })
/** * 设置浏览器头部标题 */ export const setTitle = function(title) { title = title ? `${title}` : 'NxAdmin' window.document.title = title } router.afterEach(() => { NProgress.done() // 结束Progress setTimeout(() => { const browserHeaderTitle = store.getters.browserHeaderTitle setTitle(browserHeaderTitle) }, 0) })
The above is the detailed content of How to add dynamic browser header title to Vue project. For more information, please follow other related articles on the PHP Chinese website!