From ddfc75ed45d427bb8b407133b5e2bde0e6ec581a Mon Sep 17 00:00:00 2001
From: 明梦爽 <2972214568@qq.com>
Date: 星期六, 22 一月 2022 16:22:45 +0800
Subject: [PATCH] 新闻查询功能完毕

---
 src/components/page/introduce.vue |   42 +++++++++++++++++++-----------------------
 1 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/src/components/page/introduce.vue b/src/components/page/introduce.vue
index 9fb6ac3..f9174f7 100644
--- a/src/components/page/introduce.vue
+++ b/src/components/page/introduce.vue
@@ -15,12 +15,7 @@
        <!-- 鏂伴椈鍐呭 -->
       <el-card class="box-card">
         <el-col :span="18">
-          <!-- <div v-if="newsList.length > 0">
-            <el-row class="marb10" :key="index" v-for="(item, index) in newsList">
-              {{ item.title }}
-            </el-row>
-          </div> -->
-          <div>{{ content }}</div>
+          <div>{{ this.new.content }}</div>
         </el-col>
       </el-card>
     </el-row>
@@ -40,7 +35,7 @@
       cont: '',
       menuList: [],
       newsList:[],
-      content:'',
+      new:{}  //鏂伴椈瀵硅薄
     }
   },
   created() {
@@ -51,15 +46,15 @@
   watch: {
     menuList(n,o){
       this.cont =  this.menuList[0].name;
-      this.getnews(this.menuList[0]);
-      this.getalone(this.newsList);
+      this.getnews(this.menuList[0]); //鏀瑰彉瀵硅薄锛岃彍鍗曟爮鐨勪笢瑗胯鍐欏埌鐩戝惉灞炴�ч噷杈�
     }
   },
   methods: {
+    //鑾峰彇灏忔爣棰樼殑id
     getTitle(){
       const data = Number(this.$route.query.id);
       getMinTitle(data).then(res => {
-        console.log(res);
+        // console.log(res);
         if(res.code == 200){
           this.menuList = res.data
         }
@@ -67,10 +62,12 @@
         console.log(err);
       })
     },
+    //灏忔爣棰樿彍鍗曠殑鐞冨垏鎹�
     changeMenu(val) {
       this.cont = val.name;
       this.getnews(val)
     },
+    //鑾峰彇鍒颁簡鏂伴椈鍒楄〃锛岄噷杈瑰彧鏈変竴涓璞�
     getnews(item){
       const data = {
         current:1,
@@ -78,26 +75,25 @@
         size:5
       };
       getNewsList(data).then(res => {
-        console.log(res);
+        // console.log(res);
         if(res.code == 200){
-          // if(res.data.records.length == 1){
-            this.newsList = [];
-            this.getalone(res.data.records[0]);
-          // }else{
-          //   this.content = '';
-          //   this.newsList = res.data.records
-          // }
+          this.newsList = res.data.records
+          this.getalone(this.newsList[0].id)
         }
       }).catch(error => {
         console.log(error);
       })
     },
-    getalone(item){
-      const data = item.id;
+    //鑾峰彇鏂伴椈鍐呭,寰楀埌涓�涓柊闂诲璞�
+    getalone(id){
+      const data = id;
       getnew(data).then(res => {
-        console.log(">>>>",res);
-        this.content = res.data.content;
-        this.data = res.data;
+        // console.log(res);
+        if(res.code == 200){
+          this.new = res.data;
+        }
+      }).catch(error => {
+        console.log(error);
       })
     }
   }

--
Gitblit v1.8.0