Vue.component("roll-img", {
template: `
`,
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:{
},
})