Files
ClassContent/历届学生/17届课程/wxShopApp/myWxapp/components/swiper/swiper.js
2024-09-27 02:06:13 +08:00

47 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Component({
data: {
indicatorDots: true,
vertical: false,
autoplay: true,
interval: 2000,
current: 0, // 默认第一张图
imgheights: [], //所有图片的高度
height: wx.getSystemInfoSync()['statusBarHeight'] + 50
},
properties: {
// 需要被渲染显示的图片地址数组
list: {
type: Array,
value: []
},
// 如果父组件自定义顶部导航后建议传true做边距
// 如果没有自定义那么不传数值默认false图片和顶部没有边距
padding: {
type: Boolean,
value: false
}
},
methods: {
imageLoad: function (e) {//获取图片真实宽度
var imgwidth = e.detail.width,
imgheight = e.detail.height,
ratio = imgwidth / imgheight;
console.log(imgwidth, imgheight)
//计算的高度值
var viewHeight = 750 / ratio;
var imgheight = viewHeight;
var imgheights = this.data.imgheights;
//把每一张图片的对应的高度记录到数组里
imgheights[e.target.dataset.id] = imgheight;
this.setData({
imgheights: imgheights
})
},
bindchange: function (e) {
// console.log(e.detail.current)
this.setData({ current: e.detail.current })
},
}
})