47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
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 })
|
||
},
|
||
}
|
||
}) |