vue 图片分页
<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 图片分页的更多相关文章
- 基于Vue封装分页组件
使用Vue做双向绑定的时候,可能经常会用到分页功能 接下来我们来封装一个分页组件 先定义样式文件 pagination.css ul, li { margin: 0px; padding: 0px;} ...
- ScrollView图片分页显示-简单
用到的控件: 1>UIScrollView:宽度和图片的宽度一样,因为分页的代码就一句 // 设置分页,这个分页的原理实际上是按照ScrollView的宽进行分页的,这里的图片的宽由于和Scro ...
- js/vue图片压缩
js版 新建compressImage.js,内容如下: // 将base64转换为blob(有需要可加上,没需要可不加) function convertBase64UrlToBlob(urlDat ...
- Vue图片懒加载插件
图片懒加载是一个很常用的功能,特别是一些电商平台,这对性能优化至关重要.今天就用vue来实现一个图片懒加载的插件. 这篇博客采用"三步走"战略--Vue.use().Vue.dir ...
- JS(vue iview)分页解决方案
JS(vue iview)分页解决方案 一.解决思路 使用分页组件 使用组件API使组件自动生成页面数量 调用组件on-change事件的返回值page 将交互获得的数组存在一个数组list中 通过p ...
- vue图片、背景图片路径问题
vue图片.背景图片路径问题 vue中引入图片经常会出现路径问题,在此记录一下: 1.组件中 <img> 引用图片 <img src="../assets/img/logo ...
- 基于vue的分页插件
相信大家用过很多jquery的分页插件,那这次就用一用基于vue的分页插件. 这里的环境用的是springboot 首先要引入pagehelper的jar文件,版本是1.2.3,配置文件也需要配置一下 ...
- Vue图片浏览组件v-viewer,支持旋转、缩放、翻转等操作
v-viewer 用于图片浏览的Vue组件,支持旋转.缩放.翻转等操作,基于viewer.js. 从0.x迁移 你需要做的唯一改动就是手动引入样式文件: 1 import 'viewerjs/dist ...
- IOS-UIScrollView实现图片分页
1.设置可以分页 _scrollView.pagingEnabled = YES; 2.添加PageControl UIPageControl *pageControl = [[UIPageContr ...
- vue 图片预览插件
https://github.com/daidaitu1314/vue2-preview //cnpm cnpm install vue2-preview -save //引入 import VueP ...
随机推荐
- c语言学习总结(原创)
什么是标识符? 标识符是用来标识变量.函数.类.模块,或者任何其他用户自定义项目的名称,用它来命名程序正文中的一些实体,比如函数名.变量名.类名.对象名等.如:int a1=0; const b1=& ...
- [R语言] R语言PCA分析教程 Principal Component Methods in R
R语言PCA分析教程 Principal Component Methods in R(代码下载) 主成分分析Principal Component Methods(PCA)允许我们总结和可视化包含由 ...
- [OpenCV实战]17 基于卷积神经网络的OpenCV图像着色
目录 1 彩色图像着色 1.1 定义着色问题 1.2 CNN彩色化结构 1.3 从 中恢复彩色图像 1.4 具有颜色再平衡的多项式损失函数 1.5 着色结果 2 OpenCV中实现着色 2.1 模型下 ...
- [机器学习] Yellowbrick使用笔记2-模型选择
在本教程中,我们将查看各种Scikit Learn模型的分数,并使用Yellowbrick的可视化诊断工具对它们进行比较,以便为我们的数据选择最佳的模型. 代码下载 文章目录 1 使用说明 1.1 模 ...
- Socket爬虫:Python版
简述:较为底层的爬虫实现,用于了解爬虫底层实现的具体流程,现在各种好用的爬虫库(如requests,httpx...等)都是基于此进行封装的. PS:本文只作为实现请求的代码记录,基础部分不做过多阐述 ...
- 我们来汉化IntelliJ IDEA
(原发于 GitHub Pages,2018-10-13 13:51:09) 两年前我从一名光荣的C++程序员专业为PHP程序员以后,告别了世界第一IDE Visual Studio,改用当时觉得特别 ...
- 一、tcp三次握手
(1)首先客户端向服务器端发送一段tcp报文,其中标志位为SYN,表示"请求创建新连接"序列号为sqe=x,随后进入SYN_SEND状态 (2)服务器端接受到客户端发送的tcp报文 ...
- ChatGPT/InstructGPT详解
作者:京东零售 刘岩 前言 GPT系列是OpenAI的一系列预训练文章,GPT的全称是Generative Pre-Trained Transformer,顾名思义,GPT的目的就是通过Transfo ...
- COM 进程注入技术
COM PROCESS INJECTION for RUST 项目地址:https://github.com/0xlane/com-process-inject Process Injection v ...
- vue/cli子组件style中如何使用全局图片路径