首页 > 其他分享 >vue中展示多张小图轮播每几秒走一张,支持左右点击

vue中展示多张小图轮播每几秒走一张,支持左右点击

时间:2023-08-03 10:12:14浏览次数:35  
标签:vue 轮播 regional 382 height 张小图 leftNum services display

html部分

       <div class="regional-services-list" style="overflow: hidden;" @mouseenter="stopCar()" @mouseleave="starCar()">           <div class="preIcon" @click="preChange()"> <i class="el-icon-arrow-left"></i> </div>           <div class="nextIcon" @click="nextChange()"> <i class="el-icon-arrow-right"></i> </div>           <div style="overflow: hidden;display: inline-block;height: 146px;">         <ul class="qflb" :style="{'left':leftNum+'px'}" :class="{'transition':isTransition}">           <li             v-for="(item, index) in regionalServicesList"             :key="index"             class="regional-services-item"             @click="toBlogrollUrl(item)"           >           <a               class="regional-services-link"                href="javascript:;"             >               <img class="regional-services-img" :src="item.imgpath" alt="" />             </a>                     </li>           <li             v-for="(ele, i) in regionalServicesList"             :key="i+6"             class="regional-services-item"             @click="toBlogrollUrl(ele)"           >           <a               class="regional-services-link"                href="javascript:;"             >               <img class="regional-services-img" :src="ele.imgpath" alt="" />             </a>                     </li>         </ul>       </div>       </div> css部分:   .regional-services-list{       background: #fff;       box-sizing: border-box;       padding: 51px 52px  51px 54px;       box-shadow: 0px 0px 20px rgba(38,118,168,8%);       border-radius: 8px;       position: relative;       &:hover{         .preIcon,.nextIcon{           display: block;         }       }   }   .preIcon,.nextIcon{     width: 36px;     height: 36px;     border-radius: 20px;     text-align: center;     line-height: 36px;     position: absolute;     display: none;     font-size: 16px;     background-color: rgba(0, 0, 0, 0.1);     cursor: pointer;     z-index: 99;     color: #fff;     top: 50%;     font-weight: bold;     transform: translateY(-50%);     &:hover{       background-color: rgba(0, 0, 0, 0.2);     }   }   .preIcon{     left: 10px;       }   .nextIcon{     right: 10px;   }   .regional-services-item{       width: 330px;       height: 128px;       display: inline-block;       margin-right: 52px;       vertical-align: top;       &:last-child{         margin-right: 0;       }   }   .regional-services-link{      display: block;   }   .regional-services-img{     width: 100%;     height: 100%;     cursor: pointer;   }   .regional-services-head{     margin-bottom: 40px;       } js部分:   created() {     this.starCar(); },   destroyed(){     this.stopCar();   }, methods:{  starCar(){       this.iconTime = setInterval(()=>{       this.leftNum -=382;       if (this.leftNum<=-382*(this.regionalServicesList.length+1)) {         this.isTransition = false;         this.leftNum = 0;       }else{         this.isTransition = true;       }     },3000)     },     stopCar(){       clearInterval(this.iconTime);     },     nextChange(){       if (this.leftNum<=-382*(this.regionalServicesList.length)) {       this.isTransition = false;       this.leftNum = 0;       setTimeout(()=>{         this.isTransition = true;       this.leftNum -=382;       })     }else{       this.isTransition = true;       this.leftNum -=382;     }     },     preChange(){       if (this.leftNum<0) {         this.isTransition = true;         this.leftNum +=382;       }else{       this.isTransition = false;       this.leftNum=-382*(this.regionalServicesList.length)       setTimeout(()=>{         this.isTransition = true;         this.leftNum +=382;       })     }     }, }

标签:vue,轮播,regional,382,height,张小图,leftNum,services,display
From: https://www.cnblogs.com/xiao-lei-ge/p/17602509.html

相关文章

  • 前端vue uni-app自定义精美海报生成组件
    在当前技术飞速发展的时代,软件开发的复杂度也在不断提高。传统的开发方式往往将一个系统做成整块应用,一个小的改动或者一个小功能的增加都可能引起整体逻辑的修改,从而造成牵一发而动全身的情况。为了解决这个问题,组件化开发逐渐成为了一种趋势。通过组件化开发,我们可以实现单独开......
  • vuetools的安装
    1、下载源码https://gitcode.net/mirrors/vuejs/vue-devtools/-/tree/master2、npminstall如果慢,就加上镜像npminstall--registry=https://registry.npm.taobao.org遇到的问题1:‘cross-env’不是内部或外部命令,也不是可运行的程序或批处理文件。解决1:cnpmicross-en......
  • 关于vue中同时使用v-if和nth-of-type时的bug
    问题引出需求:例如我想要在某一个ul元素中使用v-if条件时渲染2个li元素,同时第一个和第二个的样式不同,这里我使用了nth-of-type选择器去设置样式,但是当v-if条件改变时,li元素的样式没有改变,看了下开发者工具,元素对应的选择器没有改变,即使此时仅剩第二个li元素,它仍旧被nth-of-ty......
  • 不可思议!Vue拖拽插件的实战大揭秘,竟然惊人抛弃了常规选择!
    大家好,我是程序视点的小二哥因为项目上有一个在规定区域内自由拖拽的小需求,自己纯js写又有点小麻烦,就花了点时间寻找到这个小组件。介绍vue-drag-resize是一个用于拖拽,缩放的组件根据网上搜索到的使用教程,都是照着文档翻译了一遍,根本解决不了我想要的问题花了几天时间,于是记......
  • 【vue】vue3+ts+element-plus制作的vueCms后台管理系统(开源)
    我的开源项目地址:vueCms_xg......
  • vue中使用axios发送请求时在header中设置请求头发现请求发送两次
    问题:vueaxios跨域请求,在RequestHeaders加Authorization传递Token时,发现统一请求触发了两次,第一次是RequestMethod:OPTIONS请求。原因:跨域请求时,浏览器会首先使用OPTIONS方法发起一个预请求,判断接口是否能够正常通讯。如果通讯异常,则不会发送真正的请求,如果测试通讯正常,则开......
  • antd upload vue3 取消请求,取消进行中的接口请求
    在使用antdupload组件时,大文件上传等待时长太久,在上传过程中想取消上传,即取消进行中的接口请求。不解释,上代码:importaxiosfrom'axios';<a-uploadv-model:file-list="fileList"name="file":multiple="true":action=......
  • Vue学习笔记:VCA下使用provide与 inject
    在VCA模式下使用provide和inject与之前文档中VOA模式类似,不同的是需要在使用前进行importimport{provide,inject}from'vue'在此篇文档中,使用一个示例来演示provide与inject的使用功能如下:组件NavbarDetailList部署在根组件App上。在初始页面,显示Navbar与List。List组件......
  • vue-让你的组件支持v-model
    原文:https://zhuanlan.zhihu.com/p/453112282在定义vue组件时,可以提供一个model属性,用来定义组件以何种方式支持v-model。model本身是有默认值的,如下:也就是说,如果你不定义model属性,或者按照上面的方式定义model属性,当其他人使用你的自定义组件时,v-model='foo',就等......
  • VUE后台管理系统(二)
    SPU管理先搞定静态组件(类似Attr管理的页面结构)###product.Spu.index.vue<template><div><!--三级联动结构(全局组件)--><el-cardstyle="margin:20px0px;"><!--传值show过去--><CategorySelect@getCategoryId="getCate......