calamus
calamus
冬天从这里夺去的,春天会交还与你。
posts - 151,comments - 14,trackbacks - 0

 

好久没更博客了,随便写点记录下防止忘记吧。具体内容看官网吧
Vue-meta的使用

下载安装

install vue-meta

main.js 中注册


import Vue from 'vue' import VueRouter from 'vue-router' import VueMeta from 'vue-meta'  Vue.use(VueRouter)

Vue.use(VueMeta, {
  keyName: 'metaInfo',
  refreshOnceOnNavigation: true
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");

使用方法

组件中使用


export default {

  name: "about",
  metaInfo(){
        return {
            title: this.title,
            meta: [
                {
                    name:"keywords",
                    content: '213213'
                },{
                    name:"description",
                    content: '213213'
                }
            ]
        }
    },

}

路由配置中使用

const routes = [
  {
    path: "/",
    name: "home",
    component: Home
  },
  {
    path: "/home",
    name: "home",
    component: Home
  },
  {
    path: "/about",
    name: "about",   component: () =>
      import(/* webpackChunkName: "about" */ "../views/About.vue"),
     meta: {
     metaInfo: {
     title: "腾讯首页",
     keywords: "资讯,新闻,财经,房产,视频,NBA,科技,腾讯网,腾讯,QQ,Tencent",
             description: "腾讯网从2003年创立至今,已经成为集新闻信息……"

         }
    }
  }
];

 

posted on 2019-11-08 10:22  calamus  阅读(...)  评论(...编辑  收藏