首页 > 其他分享 >vue 图片分页

vue 图片分页

时间:2023-02-09 14:24:32浏览次数:39  
标签:vue 分页 title require time images article 图片 name

  <div class="activities phone">
          <!-- 动态 -->
          <div
            class="activity"
            v-for="(item, index) in imgList.slice(
              (currentPage - 1) * pageSize,
              currentPage * pageSize
            )"
            :key="index"
          >
            <!-- 动态图片 -->
            <div class="act-image-wrapper">
              <div class="img-shadow"></div>
              <img
                :src="item.url"
                class="imgCss"
                alt=""
                @click="gotoPage(item)"
              />
            </div>
            <!-- 动态元数据,包括发表日期和评论数量 -->
            <div class="activity-content">
              <!-- 动态标题 -->
              <h2 class="act-title" @click="gotoPage(item)">
                {{ item.title }}
              </h2>
              <!-- 动态内容摘要 -->
              <article @click="gotoPage(item)">
                {{ item.article }}
              </article>

              <div class="meta" @click="gotoPage(item)">
                <p class="date-published">
                  <i class="far fa-calendar"></i> {{ item.time }}
                </p>
              </div>
            </div>
          </div>
        </div>
        <!-- 分页 -->
        <br />
        <br />
        <div class="block phone">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-size="pageSize"
            layout=" prev, pager, next"
            :total="totalNum"
          >
          </el-pagination>
        </div>
data() {
    return {
      currentPage: 1, //默认显示第一页
      pageSize: 5, //默认每页显示10条
      totalNum: 15, //总页数
      imgList: [
        {
          title: this.$t("home.t36"),
          url: require("@/assets/images/greekBudget.jpg"),
          article: this.$t("home.t37"),
          name: "greekBudget",
          time: this.$t("home.t44"),
        },
        {
          title: this.$t("EU.t1"),
          url: require("@/assets/images/EUCouncil.webp"),
          article: this.$t("EU.t2"),
          name: "EUCouncil",
          time: "",
        },
        {
          title: this.$t("SETE.t1"),
          url: require("@/assets/images/SETE.png"),
          article: this.$t("SETE.t2"),
          name: "SETE",
          time: this.$t("SETE.t3"),
        },
        {
          title: this.$t("logistics.t1"),
          url: require("@/assets/images/logistics.webp"),
          article: this.$t("logistics.t2"),
          name: "logistics",
          time: this.$t("logistics.t3"),
        },
        {
          title: this.$t("hellenistical.t1"),
          url: require("@/assets/images/hellenistical.jpg"),
          article: this.$t("hellenistical.t2"),
          name: "hellenistical",
          time: this.$t("hellenistical.t3"),
        },
        {
          title: this.$t("economic.t1"),
          url: require("@/assets/images/economic2.jpg"),
          article: this.$t("economic.t3"),
          name: "economic",
          time: this.$t("economic.t2"),
        },
        {
          title: this.$t("femalePresident.t1"),
          url: require("@/assets/images/femalePresident1.jpg"),
          article: this.$t("femalePresident.t3"),
          name: "femalePresident",
          time: this.$t("femalePresident.t2"),
        },
        {
          title: this.$t("port.t1"),
          url: require("@/assets/images/port1.png"),
          article: this.$t("port.t4"),
          name: "port",
          time: this.$t("port.t3"),
        },
        {
          title: this.$t("VisaIncrease.t1"),
          url: require("@/assets/images/VisaIncrease.png"),
          article: this.$t("VisaIncrease.t2"),
          name: "VisaIncrease",
          time: "",
        },
        {
          title: this.$t("DebtRelief.t1"),
          url: require("@/assets/images/DebtRelief.webp"),
          article: this.$t("DebtRelief.t4"),
          name: "DebtRelief",
          time: this.$t("DebtRelief.t2"),
        },
        {
          title: this.$t("agreement.t1"),
          url: require("@/assets/images/agreement1.jpg"),
          article: this.$t("agreement.t4"),
          name: "agreement",
          time: this.$t("agreement.t2"),
        },
        {
          title: this.$t("Shanghai.t1"),
          url: require("@/assets/images/Shanghai1.jpg"),
          article: this.$t("Shanghai.t4"),
          name: "Shanghai",
          time: this.$t("Shanghai.t2"),
        },
        {
          title: this.$t("cooperation.t1"),
          url: require("@/assets/images/cooperation1.jpg"),
          article: this.$t("cooperation.t4"),
          name: "cooperation",
          time: this.$t("cooperation.t2"),
        },
        {
          title: this.$t("VisitGreece.t1"),
          url: require("@/assets/images/VisitGreece1.jpg"),
          article: this.$t("VisitGreece.t4"),
          name: "VisitGreece",
          time: this.$t("VisitGreece.t2"),
        },
        {
          title: this.$t("SouthEurope.t1"),
          url: require("@/assets/images/SouthEurope1.jpg"),
          article: this.$t("SouthEurope.t4"),
          name: "SouthEurope",
          time: this.$t("SouthEurope.t2"),
        },
      ],
    };
  },
 created() {
    this.totalNum = this.imgList.length;

  },
methods: {  // 跳转页面
    gotoPage(item) {
      this.$router.push(item.name);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val; //动态改变
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val; //动态改变
    },}
.activity {
        // overflow: hidden;
        transition: 0.4s;
        width: 97% !important;
        background: #f4f6fa;
        overflow-x: hidden;
        /* 动态图片容器 */
        .act-image-wrapper {
          height: auto;
          width: 100%;
          overflow: hidden;
          /* 抵消activity的padding */
          margin-bottom: 0;
          position: relative;
          .img-shadow {
            z-index: 2;
            position: absolute;
            top: 0px;
            width: 100%;
            height: 100%;
            min-height: 300px;
            background: #030d37;
            opacity: 0.7;
          }
          .imgCss {
            width: 100%;
            height: 300px;
            min-height: 300px;
            object-fit: cover;
          }
        }
        .activity-content {
          width: 89%;
          height: 280px;
          margin: 0 auto;
          /* 动态标题 */
          .act-title {
            text-align: left;
            width: 100%;
            height: 68px;
            font-size: 24px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #273056;
            line-height: 34px;
            letter-spacing: 1px;
            margin-top: 22px;
            text-overflow: ellipsis;
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
          }

          /* 动态摘要 */
          article {
            width: 100%;
            height: 112px;
            font-size: 20px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #8086a0;
            line-height: 28px;
            text-align: initial;
            text-overflow: ellipsis;
            overflow: hidden;
            display: -webkit-box;
            -webkit-line-clamp: 4;
            -webkit-box-orient: vertical;
          }
          .meta {
            width: 100%;
            height: 28px;
            font-size: 20px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #8086a0;
            line-height: 28px;
            margin-top: 20px;
            text-align: initial;
          }
        }
      }
      /* 动态鼠标移上时 */
      .activity:hover {
        //     transform: translateY(-20px) scale(1.05);
        //     box-shadow: 0px 0px 36px rgba(0, 0, 0, 0.1);
        background: #030d37;

        .img-shadow {
          display: none;
        }
        .act-title {
          color: #ffffff;
        }
        article {
          color: #b3bada;
        }
        .meta {
          color: #b3bada;
        }
      }

 

标签:vue,分页,title,require,time,images,article,图片,name
From: https://www.cnblogs.com/hanxue-chen/p/17099133.html

相关文章

  • vue 前端, 树形菜单的回显
      //树菜单回显(多级)  changeDetSelect(key,treeData){   letarr=[];//在递归时操作的数组   letreturnArr=[];//存放结果的数组 ......
  • 《Vue.js 设计与实现》读书笔记 - 第14章、内建组件和模块
    第14章、内建组件和模块14.1KeepAlive组件的实现原理KeepAlive一词借鉴了HTTP协议。KeepAlive组件可以避免组件被频繁的销毁/重建。本质是缓存管理,再加上特殊的挂......
  • 【Vue】父子组件传值、方法引用
    父子组件值、方法引用1、值1.1父组件获取子组件值父组件<template><div><button@click="getChildValue">click</button><childref="child"></child>......
  • CSS 3.0中图片颜色过滤特效
    给大家分享一个用CSS3.0写的图片颜色过滤的特效,效果如下:以下是代码实现,欢迎大家复制粘贴和收藏。<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><m......
  • 富文本编辑器实现网页图片自动上传
    ​ 图片的复制无非有两种方法,一种是图片直接上传到服务器,另外一种转换成二进制流的base64码目前限chrome浏览器使用首先以um-editor的二进制流保存为例:打开umeditor.j......
  • Vue 常用
    阅读目录​​Vue3中八个生命周期函数​​​​js动态添加对象属性​​​​js遍历对象​​​​第一种:for......in​​​​第二种​​​​第三种:使用Object.getOwnPropertyNa......
  • 前端图片压缩方案及代码实现
    1.为什么要进行图片压缩?随着互联网的发展,图片在各种网站和应用中铺天盖地,运营人员在后台管理系统中上传图片时常常忽略的图片的体积大小,随之产生的带宽和服务器容量也大大......
  • Vue 的优化技巧
    演示代码使用Vue3+ts+Vite编写,但是也会列出适用于Vue2的优化技巧,如果某个优化只适用于Vue3或者Vue2,我会在标题中标出来。代码优化v-for中使用key使用v......
  • JavaScript插件 图片裁剪photoClip
    阅读目录​​JavaScript插件图片裁剪photoClip​​​​1、截图​​​​2、代码​​​​后台接收并处理图片代码​​JavaScript插件图片裁剪photoClip页面裁剪图片得到bas......
  • Vue2.9.6安装element-ui
    阅读目录安装element-ui源码路由文件:E:\node\vue296\src\router\index.js入口:E:\node\vue296\src\main.js组件:E:\node\vue296\src\components\Count.vue......