(vue)新闻列表与图片对应显示,体现选中、移入状态

本文主要是介绍(vue)新闻列表与图片对应显示,体现选中、移入状态,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

(vue)新闻列表与图片对应显示,体现选中、移入状态


项目背景:郑州院XX项目首页-新闻展示模块,鼠标移入显示对应图片,且体现选中和移入状态


首次加载:
在这里插入图片描述

切换列表后:

在这里插入图片描述


html:

<el-row :gutter="20" class="process-content"><el-col :span="10"><div class="block"> //图片<el-image :src="picUrl" class="newImage" :fit="fit"><div slot="placeholder" class="image-slot">加载中<span class="dot">...</span></div></el-image></div></el-col><el-col :span="14"><div class="newsBody"><divv-for="(item, index) of newsList.slice(0, 4)"//截取收据前4个:key="index"class="news-list":class="{'active' : change === index}" //选中样式tabindex="1" //选中@mouseenter="handleMouseEnter(item)" //移入@mouseleave="handleMouseLeave(item)" //移出@click="newClick(item,index)" //点击><span class="newsTitle">{{ item.title }}</span><div class="newsDesc">{{ item.keywords }}</div></div></div></el-col>
</el-row>

js:

data() {return {      newsList: [{picUrl:'https://fuss...10.jpeg',title: '...技术',keywords: '通过改变...'},{picUrl:null,title: '加热...',keywords: '...'},...],picUrl: null,change: 0, //初始选中第一条新闻fits: 'fill' // 'fill', 'contain', 'cover', 'none', 'scale-down'}
},methods:{// 获取新闻getNews() {newsSelect().then((res) => { this.newsList = res.data.list;this.picUrl = this.newsList[0].picUrl; //初始显示第一条新闻的图片});},// 移入handleMouseEnter(item, index) {//若返回图片地址为空则给默认图片if (item.picUrl !== null) {this.picUrl = item.picUrl} else {this.picUrl = require('@/assets/images/dashboard/noData.png') }},// 移出handleMouseLeave() {//恢复被选中项的图片this.picUrl = this.newsList[this.change].picUrl !== null ? this.newsList[this.change].picUrl : require('@/assets/images/dashboard/noData.png')},// 点击newClick(item, index) {this.change = index //选中的项}}

css:

.process-content {height: 480px;margin-top: 20px;.block{width: 100%;height: 400px;display: flex;justify-content: center;align-items: center;.newImage{height: 400px;}}.newsBody {height: 400px;.news-list{height: 70px;border-bottom: 1px solid #d1cfcf;padding: 15px 30px;transition: all 0.3s;overflow: hidden;.newsTitle {font-size: 20px;font-weight: 600;}.newsDesc {color: #666;font-size: 14px;margin-top: 10px;}}//重点.news-list:hover,.news-list:focus{color: #fff;background-color: #065de0;.newsDesc {color: #fff;}}}
}
//重点
.active{color: #fff;background-color: #065de0;.newsDesc {color: #fff !important;}
}

这篇关于(vue)新闻列表与图片对应显示,体现选中、移入状态的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/833358

相关文章

JAVA读取MongoDB中的二进制图片并显示在页面上

1:Jsp页面: <td><img src="${ctx}/mongoImg/show"></td> 2:xml配置: <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001

vue, 左右布局宽,可拖动改变

1:建立一个draggableMixin.js  混入的方式使用 2:代码如下draggableMixin.js  export default {data() {return {leftWidth: 330,isDragging: false,startX: 0,startWidth: 0,};},methods: {startDragging(e) {this.isDragging = tr

据阿谱尔APO Research调研显示,2023年全球髓内钉市场销售额约为4.7亿美元

根据阿谱尔 (APO Research)的统计及预测,2023年全球髓内钉市场销售额约为4.7亿美元,预计在2024-2030年预测期内将以超过3.82%的CAGR(年复合增长率)增长。 髓内钉市场是指涉及髓内钉制造、分销和销售的行业。髓内钉是一种用于整形外科手术的医疗器械,用于稳定长骨骨折,特别是股骨、胫骨和肱骨。髓内钉通常由不銹钢或钛等材料制成,并插入骨的髓管中,以在愈合过程中提供结构支

vue项目集成CanvasEditor实现Word在线编辑器

CanvasEditor实现Word在线编辑器 官网文档:https://hufe.club/canvas-editor-docs/guide/schema.html 源码地址:https://github.com/Hufe921/canvas-editor 前提声明: 由于CanvasEditor目前不支持vue、react 等框架开箱即用版,所以需要我们去Git下载源码,拿到其中两个主

React+TS前台项目实战(十七)-- 全局常用组件Dropdown封装

文章目录 前言Dropdown组件1. 功能分析2. 代码+详细注释3. 使用方式4. 效果展示 总结 前言 今天这篇主要讲全局Dropdown组件封装,可根据UI设计师要求自定义修改。 Dropdown组件 1. 功能分析 (1)通过position属性,可以控制下拉选项的位置 (2)通过传入width属性, 可以自定义下拉选项的宽度 (3)通过传入classN

js+css二级导航

效果 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Con

基于Springboot + vue 的抗疫物质管理系统的设计与实现

目录 📚 前言 📑摘要 📑系统流程 📚 系统架构设计 📚 数据库设计 📚 系统功能的具体实现    💬 系统登录注册 系统登录 登录界面   用户添加  💬 抗疫列表展示模块     区域信息管理 添加物资详情 抗疫物资列表展示 抗疫物资申请 抗疫物资审核 ✒️ 源码实现 💖 源码获取 😁 联系方式 📚 前言 📑博客主页:

vue+el国际化-东抄西鉴组合拳

vue-i18n 国际化参考 https://blog.csdn.net/zuorishu/article/details/81708585 说得比较详细。 另外做点补充,比如这里cn下的可以以项目模块加公共模块来细分。 import zhLocale from 'element-ui/lib/locale/lang/zh-CN' //引入element语言包const cn = {mess

vue同页面多路由懒加载-及可能存在问题的解决方式

先上图,再解释 图一是多路由页面,图二是路由文件。从图一可以看出每个router-view对应的name都不一样。从图二可以看出层路由对应的组件加载方式要跟图一中的name相对应,并且图二的路由层在跟图一对应的页面中要加上components层,多一个s结尾,里面的的方法名就是图一路由的name值,里面还可以照样用懒加载的方式。 页面上其他的路由在路由文件中也跟图二是一样的写法。 附送可能存在

vue+elementUI下拉框联动显示

<el-row><el-col :span="12"><el-form-item label="主账号:" prop="partyAccountId" :rules="[ { required: true, message: '主账号不能为空'}]"><el-select v-model="detailForm.partyAccountId" filterable placeholder="