vue modify the browser title

The main idea:

1. Route header can be obtained from the current page, then the value set by document.title, add <title> tag outermost index.html page

import router from './router'
router.beforeEach(async (to, from, next) => {
document.title = to.meta.title
})

2. (mainly for proxy site) If you want to get that data in App.vue page modify data obtained from the database, to be stored in the local cache (window.localStorage.setItem),
document.title then take from the local cache value (window.localStorage.getItem) (but there is a small problem, start to set the default value into the page)

Guess you like

Origin www.cnblogs.com/GGDong/p/11208734.html