亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - vue2.0如何設(shè)定 網(wǎng)頁標(biāo)題 關(guān)鍵字 描述
世界只因有你
世界只因有你 2017-06-26 10:52:29
0
2
1171

vue2.0如何設(shè)定 網(wǎng)頁標(biāo)題title 和meta標(biāo)籤裡面的 關(guān)鍵字和描述呢?想動(dòng)態(tài)改變,切換路由或在其他情況下,動(dòng)態(tài)改變這三個(gè)地方

世界只因有你
世界只因有你

全部回覆(2)
黃舟

在router.js中如下設(shè)定

import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

const router = new Router({
  routes: [{
      path: '/login',
      component: Login,
      meta: { title: '登錄' }
    }, {
      path: '/register',
      component: Register,
      meta: { title: '注冊(cè)' }
    }
  ]
})
// 全局配置
router.beforeEach((to, from, next) => {
  // Change doc title
  document.title = to.meta.title || 'Unknow title'
  document.querySelector('meta[name="keywords"]').setAttribute('content', 'keywords')
  document.querySelector('meta[name="description"]').setAttribute('content', 'description')
})
小葫蘆

入口檔案的基本標(biāo)籤都是可以被操作的
你可以在Router
router.beforeEach((to, from, next) => {
//這裡操作DOM
// ...
/* console.log (to);
console.log(from);*/
next();
})

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板