/** * 顶部header */ Vue.component("swiper-row", { template: `
`, props: { srcList: { type: Array, } }, data() { return { btnNav: 1, //造价 costIndex: 0, direction: 'right', costInterval: undefined, } }, mounted() { this.init() }, methods: { //初始化 init() { // 图片定时器 // 造价 定时器 this.costInterval = setInterval(this.manufacturingCostRoll, 2000); this.$nextTick(() => { var width = $(".liSmallBox").innerWidth() + 28 const a = $(this.$refs['width']).width = width * this.srcList.length console.log(a) }) }, btnLeft() { this.direction = 'left' this.manufacturingCostRoll() }, btnRight() { this.direction = 'right' this.manufacturingCostRoll() }, manufacturingCostRoll() { var width = $(".liSmallBox").innerWidth() + 28 if (this.direction == 'right') { if (this.costIndex == 7) { this.costIndex = 0 } else { this.costIndex = this.costIndex + 1 } } else { if (this.costIndex == 0) { this.costIndex = 7 } else { this.costIndex = this.costIndex - 1 } } $(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); }, onClickPoint(n) { this.btnNav = n; }, }, })