53 lines
1.4 KiB
JavaScript
53 lines
1.4 KiB
JavaScript
|
|
Vue.component("roll-img", {
|
|
template: `
|
|
<div class="roll-img" ref="rollImgMax" @mouseout="costMouseout" @mouseover="costMouseover">
|
|
<div class="roll-img-list" :style="{'width': list.length * 210 + 'px'}">
|
|
<div class="roll-img-info" v-for="item in list">
|
|
<el-image style="width: 180px; height: 180px" fit="cover"
|
|
:src="item" :preview-src-list="list"></el-image>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
`,
|
|
props: {
|
|
list:{
|
|
type:Array
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
costIndex:0,
|
|
imgRollInterval:undefined,
|
|
}
|
|
},
|
|
mounted(){
|
|
this.init()
|
|
},
|
|
methods: {
|
|
init(){
|
|
// 图片轮播 定时器
|
|
this.imgRollInterval = setInterval(this.imgRoll,3000);
|
|
},
|
|
imgRoll(){
|
|
var width = $(".roll-img-info").innerWidth()
|
|
if(this.costIndex == this.list.length-2){
|
|
this.costIndex = 0
|
|
}else{
|
|
this.costIndex = this.costIndex + 1
|
|
}
|
|
$(this.$refs.rollImgMax).animate({scrollLeft:(width*this.costIndex)+'px'})
|
|
},
|
|
costMouseover(){
|
|
clearInterval(this.imgRollInterval);
|
|
},
|
|
costMouseout(){
|
|
this.imgRollInterval=setInterval(this.imgRoll,3000);
|
|
},
|
|
},
|
|
watch:{
|
|
|
|
},
|
|
|
|
})
|