Open soonfy opened 6 years ago
const router = new Router({ mode: 'history', base: process.env.BASE_URL, routes: [ { path: '/index', name: 'index', component: () => import(/* webpackChunkName: "about" */ './views/Index.vue'), meta: { title: '首页' } }] }) router.beforeEach((to, from, next) => { /* 路由发生变化修改页面title */ console.log(to) if (to.meta.title) { document.title = to.meta.title } else { document.title = '默认title' } next() })
async loadData(id) { let data = await this.$http.get(`/${id}/`) document.title = data.name }
soonfy
固定 title
异步设置 title
soonfy