[vue2] Deje que el navegador muestre el título correspondiente según el menú actual

Este método solo es aplicable a vue2, vue3 no puede cambiar el título del navegador a través de document.title

router.beforeEach((to, from, next) => {
    
    
	const newmap = {
    
    
		'/路由地址': '应用管理1 | 哈哈系统',
		'/路由地址': '应用管理2 | 哈哈系统',
		'/路由地址': '应用管理3 | 哈哈系统',
		'/路由地址': '应用管理4 | 哈哈系统',
		'/路由地址': '应用管理5 | 哈哈系统',
	}
	for(let key in newmap) {
    
    
		if(to.path.includes(key)) {
    
    
			document.title = newmap[key]
			next()
		}
	}
})

Supongo que te gusta

Origin blog.csdn.net/bbt953/article/details/132385244
Recomendado
Clasificación