vue组件中的轮播实现
一、直接上代码
<template>
<el-row class="Slide">
<el-row class="title">{{i18n[$lang].title}}</el-row>
<el-row class="sub-title">{{i18n[$lang].subTitle}}!</el-row>
<el-row class="slide-content" @mouseenter.native="onStop" @mouseleave.native="onStart">
<img class="content-img" :src="`${$url.aliyun}${contents[selected-1].img}`" :alt="contents[selected-1].content.title">
<el-col class="content">
<el-row class="content-title">{{contents[selected-1].content.title | capitalize(true)}}<span>-{{contents[selected-1].name}}</span></el-row>
<el-row class="content-article">{{contents[selected-1].content.article}}</el-row>
<router-link class="router" :to="`/${$route.meta.lang}/login`">{{$t("common.readMore") | upperCase}}</router-link>
</el-col>
</el-row>
<el-row class="slide-controll">
<button v-for="(content,index) in contents" :class="{selected:selected===index+1}" @mouseenter="onSelect(index)" @mouseleave="onStart">{{content.name}}</button>
</el-row>
</el-row>
</template> <script>
export default {
data() {
return {
i18n: {
en: {
title: 'Functional Introduction',
subTitle: 'GIPC, GIIC, GIRC help you to complete your investment quickly'
},
cn: {
title: '功能介绍',
subTitle: 'GIPC, GIIC, GIRC助您快速完成您的投资'
}
},
contents: [{
name: 'GIPC',
img: '/static/img/home/GIPC.png',
content: {
title: 'global investment project cloud',
article: 'Global SME CEOs are major users. 100% Projects have been reviewed by PNC. At the same time, CEOs can upload their own projects automatically to the platform. Global financing and markets are their focus'
}
}, {
name: 'GIIC',
img: '/static/img/home/GIIC.png',
content: {
title: 'global investment investor cloud',
article: 'The investor pool consists mainly of Chinese investors. Introductions on the ability, background, current situation and development of investors are made to ensure that users can find the fittest investors in the shortest period of time'
}
}, {
name: 'GIRC',
img: '/static/img/home/GIRC.png',
content: {
title: 'global investment report cloud',
article: 'Providing you with Macro Industry Analysis, Case Analysis, and Corporate Valuation Reports Exclusive Customized Report across the globes'
}
}],
selected: 1,
timer: null,
speed: 5000
};
},
mounted() {
this.onStart();
},
methods: {
onNext() {
this.selected = this.selected >= this.contents.length ? 1 : this.selected + 1;
},
onStart() {
this.timer = this.contents.length > 1 ? setInterval(this.onNext, this.speed) : null;
},
onStop() {
clearInterval(this.timer);
},
onSelect(index) {
this.onStop();
this.selected = index + 1;
}
},
beforeDestroy() {
this.onStop();
}
};
注意:
- mouseenter: 在鼠标光标从元素外部首次移动到元素范围之内时触发。这个事件不冒泡,而且在光标移动到元素的后代元素上不会触发。
- mouseleave: 在鼠标光标从元素内部首次移动到元素范围之外时触发。这个事件不冒泡,而且在光标移动到元素的后代元素上不会触发。
- mouseover : 在鼠标指针位于一个元素外部,然后用户将其首次移入该元素内部时触发。(外部包括元素的子元素,元素的父元素,元素的相邻元素等)
- mouseout : 在鼠标指针位于一个元素内部,然后用户将其首次移至外部时触发。(外部包括元素的子元素,元素的父元素,元素的相邻元素等)
setInterval() 方法可按照指定的周期(以毫秒计)来调用函数或计算表达式。
setInterval() 方法会不停地调用函数,直到 clearInterval() 被调用或窗口被关闭。由 setInterval() 返回的 ID 值可用作 clearInterval() 方法的参数。
提示: 1000 毫秒= 1 秒。
提示: 如果你只想执行一次可以使用 setTimeout() 方法。http://www.runoob.com/jsref/met-win-setinterval.html
vue组件中的轮播实现的更多相关文章
- 后盾网lavarel视频项目---Vue项目使用vue-awesome-swiper轮播插件
后盾网lavarel视频项目---Vue项目使用vue-awesome-swiper轮播插件 一.总结 一句话总结: vue中的插件的使用和js插件的使用一样的简单,只是vue插件的引入过程有些不同 ...
- 循序渐进BootstrapVue,开发公司门户网站(4)--- 使用b-carousel-slide组件实现图片轮播以及vue-awesome-swiper实现图片滑动展示
在BootstrapVue组件库里面,提供了很多对Bootstrap同等类似的组件封装,其中图片轮播可以采用b-carousel-slide组件实现,而有一些小的图片,如客户/合作伙伴Logo或者友情 ...
- ReactNative新手学习之路04 组件化开发轮播图swiper支持安卓和IOS
react native 新手之路04 组件化开发轮播图swiper支持安卓和IOS npm install react-native-carousel --save git 地址Properties ...
- android中广告轮播图总结
功能点:无限轮播.指示点跟随.点击响应.实现思路: 1.指示点跟随,指示点通过代码动态添加,数量由图片数量决定. 在viewpager的页面改变监听中,设置点的状态选择器enable,当前页时,set ...
- angularjs中使用轮播图指令swiper
我们在angualrjs移动开发中遇到轮播图的功能 安装 swiper npm install --save swiper 或者 bower install --save swiper 引入文件 ...
- 使用BootStrap框架中的轮播插件
在使用bootstrap框架中的轮播插件时,效果做出来后,无法通过点击小圆行的按钮来选择特定的图片. 后面发现是最开始的<div>标签中少写了一个id.一开始<div>标签是这 ...
- Vue组件中引入jQuery
一.安装jQuery依赖 在使用jQuery之前,我们首先要通过以下命令来安装jQuery依赖: npm install jquery --save # 如果你更换了淘宝镜像,可以使用cnpm来安装, ...
- vue组件中的样式属性:scoped,解决在父组件中无法修改子组件样式问题
Scoped CSS规范是Web组件产生不污染其他组件,也不被其他组件污染的CSS规范. vue组件中的style标签标有scoped属性时表明style里的css样式只适用于当前组件元素,它是通过使 ...
- vue组件中的样式属性--scoped
Scoped CSS Scoped CSS规范是Web组件产生不污染其他组件,也不被其他组件污染的CSS规范. vue组件中的style标签标有scoped属性时表明style里的css样式只适用于当 ...
随机推荐
- SenseTime Ace Coder Challenge 暨 商汤在线编程挑战赛 E. 疯狂计数
1.改高精度 :float/double的精度为x位,小数部分最多x+x位(乘法和加法),整数部分<1000000*1000000/2=5 * 10^11 2.分成整数部分和小数部分分别存储,貌 ...
- 解决Anaconda4.2 Navigator打不开的问题
参照博客:http://blog.csdn.net/k3v1n1990s/article/details/72975528?utm_source=itdadao&utm_medium=refe ...
- 主角场景Shader效果:遮挡透明
基本原理:被遮挡的部分关闭深度写入, 显示透明效果:未被遮挡的部分不关闭深度测试,显示正常贴图效果,即使用两个Pass即可. Pass1:关闭深度写入(ZWrite Off),深度测试渲染较远的物体, ...
- [洛谷P4491] [HAOI2018]染色
洛谷题目链接:[HAOI2018]染色 题目背景 HAOI2018 Round2 第二题 题目描述 为了报答小 C 的苹果, 小 G 打算送给热爱美术的小 C 一块画布, 这块画布可 以抽象为一个长度 ...
- Java8 新特性 Streams map() 示例
在Java 8中stream().map(),您可以将对象转换为其他对象.查看以下示例: 1.大写字符串列表 1.1简单的Java示例将Strings列表转换为大写. TestJava8.java p ...
- iOS AES128 CBC No Padding加密解密
最近的项目中数据传输用到加密,项目选择了AES128 CBC No Padding加密方式,PHP和Android方面的代码网上太多了.但是唯独没有iOS的,但是也有别的写法,但不是是AES128 C ...
- 悲催的IE6 七宗罪大吐槽(带解决方法)第二部分
三.position:fixed无效 今天在IE6上遇到一个bug,本来想做一个消息提示框,让他在页面右上角停留一段时间后消失,这段时间内提示框随着页面的下拉一直出现在浏览器可见区的顶部,于是我用到了 ...
- 美轮美奂!9款设计独特的jQuery/CSS3全新应用插件(下拉菜单、动画、图表、导航等)
今天要为大家分享9款设计非常独特的jQuery/CSS3全新应用插件,插件包含菜单.jQuery焦点图.jQuery表单.jQuery图片特效等.下面大家一起来看看吧. 1.jQuery水晶样式下拉导 ...
- xgraph和gnuplot初体验
今天分别体验了一下xgraph和gnuplot. xgraph是ns2自带的画图工具,使用很简单.它的标准的数据文件是ascii文本文件,每一行两个数据,以空格隔开,这样就有了两列数据.把这样的文 ...
- SQL Server 将Id相同的字段合并,并且以逗号隔开
例如:有表MO_Cook,字段:FoodRoom,name 有如下数据: 要求:将FoodRoom中值相同的字段合并成一行,并将name的值用逗号隔开. 需要用到:STUFF函数. 查询语句如下: ...