明梦爽
2022-01-26 08e0f4f66d2e39a19b91e8e2fe1bcad75569d4b8
src/views/school.vue
@@ -1,36 +1,51 @@
<template>
  <div>
    <el-row type="flex" justify="space-between" class="underline">
      <span>学院动态</span>
      <span @click="goMore('学院动态')">更多<i class="el-icon-d-arrow-right"></i> </span>
      <span class="color"><b>学院动态</b></span>
      <span @click="goMore('学院动态')" class="liPointer"
        >更多<i class="el-icon-d-arrow-right"></i>
      </span>
    </el-row>
    <div>
    <div style="max-height:420px;overflow:hidden;">
      <ul>
        <li :key="index" v-for="(item, index) in schoolList">
          <!-- <a href="item.path"> {{ item.title }} </a> -->
          <!-- <router-link :to="{name:'schoolMessage',params:{id:item.id}}" >{{ item.title }} </router-link> -->
          <div @click="toSchoolMsg(item.title)"> {{ item.title }} </div>
        <li :key="index" v-for="(item, index) in schoolList" class="liPointer">
          <div @click="toSchoolMsg(item.id)" class="bgc mart10">
            {{ item.title }}
          </div>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
import {getNewsList} from '../api/api'
export default {
  name: 'school',
  data() {
    return {
      schoolList: [
        { id: '1',title: '学校状态1' },
        { id: '2',title: '学校状态2' },
        { id: '3',title: '学校状态3' },
        { id: '4',title: '学校状态4' },
        { id: '5',title: '学校状态5' },
        { id: '6',title: '学校状态6' }
      ]
      schoolList: [],
    }
  },
  created() {
    this.getnews()
  },
  methods:{
    getnews(){
      const data = {
        current:1,
        newsCategoryId:44,
        size:6
      }
      getNewsList(data).then(res => {
        console.log(res);
        if(res.code == 200){
          this.schoolList = res.data.records
        }
      }).catch(error => {
        console.log(error);
      })
    },
    //前往更多信息页面
    goMore(val){
      this.$router.push({
        path:'moreMessage',
@@ -39,11 +54,12 @@
        }
      })
    },
    toSchoolMsg(t) {
    //前往信息展示页面
    toSchoolMsg(id) {
      this.$router.push({
        path: 'schoolMessage',
        path: '/home/news',
        query: {
          title:t
          id:id
        }
      })
    }
@@ -52,7 +68,7 @@
</script>
<style lang="less" scoped>
.underline {
  border-bottom: 1px solid rgb(0, 110, 215);
  border-bottom: 1px solid rgb(1, 72, 153);
}
ul {
  padding-left: 0;
@@ -65,4 +81,9 @@
a {
  text-decoration: none;
}
.bgc {
  background: rgb(241, 241, 241);
  height: 55px;
  line-height: 55px;
}
</style>