av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

Vue實現無縫輪播效果

瀏覽:5日期:2022-09-30 17:22:51

本文實例為大家分享了Vue實現無縫輪播效果的具體代碼,供大家參考,具體內容如下

代碼

1.子組件代碼

代碼如下(示例):

<template> <div> <div @mouseenter='mouse' @mouseleave='mouseleave'> <ul class='box1'><li> <img :src='http://www.4tl426be.cn/bcjs/n' v-for='(n, i) in imgs' :key='i' alt='' : : /></li> </ul> <p @click='left'>&lt;</p> <p @click='right'>></p> </div> </div></template>

script代碼如下(示例):

<script>export default { name: 'Lunbo', props: ['imgs'], data() { return { // js中使用圖片,需要采用require導入 index: 1, hasAni: true, istrue: true, }; }, methods: { mouse() { clearInterval(this.timer); }, mouseleave() { this.timer = setInterval(() => {this.index++;this.hasAni = true;if (this.index == this.imgs.length - 1) { setTimeout(() => { this.index = 0; this.hasAni = false; }, 750);} }, 1500); }, right() { if (this.istrue) {this.index++;this.hasAni = true;this.istrue = false;if (this.index == this.imgs.length - 1) { setTimeout(() => { this.index = 1; this.hasAni = false; }, 750);}setTimeout(() => { this.istrue = true;}, 1000); } }, left() { if (this.istrue) {this.index--;this.hasAni = true;this.istrue = false;if (this.index == 0) { setTimeout(() => { this.index = this.imgs.length - 1; this.hasAni = false; }, 750);}setTimeout(() => { this.istrue = true;}, 1000); } }, }, activated() { console.log(1); this.timer = setInterval(() => { this.index++; this.hasAni = true; if (this.index == this.imgs.length - 1) {setTimeout(() => { this.index = 0; this.hasAni = false;}, 750); } }, 1500); }, decativated() { clearInterval(this.timer); },};</script>

css

<style scoped>p { width: 30px; height: 60px; background-color: rgba(46, 139, 86, 0.356); line-height: 60px; font-size: 24px; position: absolute; top: 105px;}.tt { left: 0;}.tt1 { right: 0;}.box { width: 500px; height: 300px; margin: 100px auto; position: relative; overflow: hidden;}.box1 img { position: absolute; left: 0px; top: 0; width: 500px; height: 300px;}.animaton { transition: left 0.75s;}</style>

2.父組件代碼

父組件

<keep-alive> <Lunbo :imgs='imgs' /></keep-alive>

導入模塊

import Lunbo from './components/Lunbo';

圖片數據

data() { return { imgs:[require('./assets/6.jpg'),require('./assets/1.jpg'),require('./assets/2.jpg'),require('./assets/3.jpg'),require('./assets/4.jpg'),require('./assets/5.jpg'),require('./assets/6.jpg'),require('./assets/1.jpg'), ], }

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 欧美视频在线播放 | 色综合色综合色综合 | 激情五月综合 | 国产精品久久国产精品 | 黄免费在线 | 81精品国产乱码久久久久久 | 中文字幕av一区二区三区 | 三级视频在线观看 | 91久久国产综合久久91精品网站 | 成人免费视频在线观看 | 精品免费国产一区二区三区四区 | 精品视频一区二区在线观看 | a中文在线视频 | 91在线看片 | 人操人免费视频 | 中文字幕一区在线观看视频 | 亚洲国产精品视频 | 精品国产一区二区三区免费 | 国产免费一区二区三区免费视频 | 一级片在线视频 | 日韩午夜一区二区三区 | 日韩毛片免费看 | 久久精品免费观看 | 免费在线观看一区二区 | 色小姐综合网 | 欧美在线一级 | 天天拍天天插 | 久久精品久久精品久久精品 | 精品国产乱码久久久久久丨区2区 | 久久精品国产99国产精品 | 国产亚洲欧美另类一区二区三区 | 亚洲日本免费 | 国产一区二区三区四区 | 久久一区二区三区四区 | 中文字幕在线观看第一页 | 国产99久久精品一区二区300 | 欧美a区 | 国产乱码精品1区2区3区 | 岛国二区 | 亚洲精品久久久一区二区三区 | 国产成人精品午夜 |