轮播图

<!DOCTYPE html>

<html lang="en">

 

<head>

<script type="text/javascript" src="https://unpkg.com/vue"></script>

<meta charset="UTF-8">

<title>Title</title>

<style>

* {

margin: 0;

padding: 0;

list-style: none;

background-color: black;

}

 

html {

height: 100%;

}

 

body {

height: 100%;

display: flex;

 

}

 

.app {

height: 100%;

width: 100%;

display: flex;

/* justify-content: center; */

}

 

img {

width: 500px;

height: 300px;

}

 

li {

width: 500px;

height: 300px;

border: 5px solid white;

color: white;

position: absolute;

}

 

ul {

width: 510px;

display: flex;

/* justify-content: center;

align-items: center; */

overflow: hidden;

position: relative;

}

 

.nav {

background-color: #c3c3c3;

color: white;

margin-left: 10px;

font-size: 20px;

border-radius: 50%;

padding: 0 8px;

margin-bottom: 10px;

opacity: 0.5;

}

 

.active {

opacity: 1;

}

 

li div {

margin-top: -30px;

}

 

.image-enter-active {

transition: all 1.5s linear

}

 

.image-leave-active {

transition: all 1.5s linear;

}

 

.image-enter-to {

transform: translateX(0);

}

 

.image-enter {

transform: translateX(100%);

}

 

.image-leave {

transform: translateX(0);

}

 

.image-leave-to {

transform: translateX(-100%);

}

</style>

</head>

 

<body>

<div id="app">

<div v-on:mouseover="stop()" v-on:mouseout="move()" class="app">

<transition-group tag="ul" name="image">

<li v-for="(items,index) in list" v-show="index===num" :key="index">

<img :src="items" alt="">

<div>

<span v-for="(items,index) in data" class="nav" @click="change(index)"

:class="{'active':index==num}">{{items}}</span>

</div>

</li>

</transition-group>

</div>

</div>

<script src="vue.js"></script>

 

<script>

new Vue({

el: '#app',

data() {

return {

data: ['1', '2', '3'],

time: '',

num: 0,

list: ['https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1534136662314&di=af7ec227db5e118a5626a94ab97026f3&imgtype=0&src=http%3A%2F%2Fc.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F4bed2e738bd4b31ccda81d7a8bd6277f9f2ff85f.jpg',

"https://ss3.baidu.com/-fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=4b22ec31ddc8a786a12a4c0e5708c9c7/5bafa40f4bfbfbedc5597ab474f0f736aec31ffc.jpg",

"https://ss3.baidu.com/9fo3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=87d6daed02f41bd5c553eef461d881a0/f9198618367adab4b025268587d4b31c8601e47b.jpg"

],

}

},

methods: {

play() {

this.time = setInterval(() => {

this.num++;

if (this.num == 3) {

this.num = 0

}

 

}, 2000)

},

change(i) {

this.num = i

},

stop() {

clearInterval(this.time)

},

move() {

this.play();

}

},

created() {

this.play();

},

 

})

</script>

</body>

 

</html>

转载于:https://my.oschina.net/u/4004801/blog/3073834

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值