/**
* 顶部header
*/
Vue.component("swiper-jiaoyu", {
template: `
`,
props: {
imglist: {
type: Array,
}
},
data() {
return {
CircleIndex: 0,
costIndex: 0,
direction: 'right',
costInterval: undefined,
}
},
mounted() {
this.init()
},
methods: {
//初始化
init() {
// 图片定时器
this.costInterval = setInterval(this.manufacturingCostRoll, 2000);
this.$nextTick(() => {
var width = $(".smallBox").innerWidth() + 76
const a = $(this.$refs['width']).width = width * this.imglist.length
console.log(a)
})
},
manufacturingCostRoll() {
var width = $(".smallBox").innerWidth() + 76
if (this.direction == 'right') {
if (this.costIndex == this.imglist.length-2) {
this.costIndex = 0
} else {
this.costIndex = this.costIndex + 1
}
} else {
if (this.costIndex == 0) {
this.costIndex = this.imglist.length-2
} else {
this.costIndex = this.costIndex - 1
}
}
this.CircleIndex = this.costIndex
$(this.$refs.modifyContent).animate({scrollLeft: (width * this.costIndex) + 'px'})
this.direction = 'right'
// console.log(123)
}
,
costMouseover() {
clearInterval(this.costInterval);
}
,
costMouseout() {
this.costInterval = setInterval(this.manufacturingCostRoll, 2000);
}
},
})