第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

vue-router改title,改完router-view消失

vue-router改title,改完router-view消失

汪汪一只貓 2018-08-23 20:10:11
貼代碼:想每次進一個路由的時候,改一下document.titleimport Vue from 'vue'import Router from 'vue-router'Vue.use(Router) const router = new Router({   routes: [    //首頁     {       path: '/',       name: 'index',       component: () => import('../components/index.vue'),       meta: {         title: '首頁'       }     },    //詳情頁     {       path: '/detail',       name: 'Detail',       component:  () => import('../components/Detail.vue'),       meta: {         title: '詳情頁'       }     }   ] }); router.beforeEach((to, from, next) => {  if(to.meta.title) {    document.title = to.meta.title;   } });export default router去掉router.beforeEach之后,router-view就出現(xiàn)了,然后document.title沒改,加回router.beforeEach之后,router-view就消失了,然后document.title改了。
查看完整描述

2 回答

?
波斯汪

TA貢獻1811條經(jīng)驗 獲得超4個贊

router.beforeEach((to, from, next) => {  if(to.meta.title) {
    document.title = to.meta.title;
  }  next(); // 記得調(diào)用 next});


查看完整回答
反對 回復(fù) 2018-08-26
  • 2 回答
  • 0 關(guān)注
  • 1260 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號