Newer
Older
KaiFengH5 / src / views / home / home_news.vue
@鲁yixuan 鲁yixuan on 26 Aug 1 KB updata
<template>
  <!-- 培训宣传 -->
  <div id="home_workbench">
    <div class="newsList" v-for="item in tableData" @click="gotoNews(item)" :key="item.id">
      <div class="left">
        <p class="title">{{ item.title }}</p>
        <p>{{ item.address }}</p>
        <p>{{ item.trainTime }}</p>
      </div>
      <div class="right">
        <img v-if="item.filelist.length > 0" :src="item.filelist[0].url" alt="" class="zp" />
        <img v-else src="@/assets/images/mrzp.png" alt="" class="zp" />
      </div>
    </div>
  </div>
</template>

<script setup name="home_workbench">
import { specialNavList } from '@/api/SpongeCulture.js';
import { ref, reactive, toRefs, onMounted } from 'vue';

import { useRouter } from 'vue-router';
const router = useRouter();
const tableData = ref([]);
/** 获取查询数据列表 */
function getDataList() {
  specialNavList().then((response) => {
    tableData.value = response.data;
  });
}
// 跳转详情
function gotoNews(item) {
  router.push({
    path: '/newsdetail',
    query: { id: item.id },
  });
}

onMounted(() => {
  getDataList();
});
</script>

<style lang="less" scoped>
#home_workbench {
  width: 100%;
  height: calc(100% - 5px);
  background: #f2f1f6;
  // background: red;
  overflow: auto;
  .newsList {
    margin: 15px 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    background: #ffffff;
    .left {
      flex: 1;
      margin-right: 20px;
      overflow: auto;
      p.title {
        height: 35px;
        line-height: 35px;
        overflow: hidden; //超出隐藏
        white-space: nowrap; //不折行
        text-overflow: ellipsis; //溢出显示省略号
        font-size: 28px;
        margin: 15px auto;
      }
    }
    .right {
      width: 250px;
      img {
        width: 250px;
        height: 150px;
      }
    }
  }
}
</style>