Jelajahi Sumber

增加新闻 meta

wangguoyu 4 tahun lalu
induk
melakukan
9a5f163e56
1 mengubah file dengan 14 tambahan dan 2 penghapusan
  1. 14 2
      pages/news/_id.vue

+ 14 - 2
pages/news/_id.vue

@@ -44,6 +44,7 @@
   export default {
     name:     'news_id',
     layout:   'templateB',
+
     async asyncData({ params, $axios, store }) {
       // 设置选中菜单
       store.commit('setActiveNav', '/news');
@@ -55,8 +56,7 @@
         const res = await $axios.post(url, opt);
         const url2 = '/home/news/newest';
         const res2 = await $axios.post(url2);
-
-
+          console.log(res);
         return {
           infoData:   res.data.data,
           newestData: res2.data.data.data,
@@ -65,6 +65,18 @@
         return {};
       }
     },
+    head(){
+      return {
+        title: this.infoData.keyword,
+        meta: [
+          {
+            hid: this.infoData.keyword,
+            name: 'description',
+            content: this.infoData.intro
+          }
+        ]
+      }
+    },
     computed: {
       baseUrl() {
         return this.getBaseUrl;