Commit 37d55bc2 by 李嘉林

公告组件动态计算高度

parent db468fbd
......@@ -18,10 +18,12 @@ Component({
singleImg: '',
CommonHeight: 0,
NoticeMargin: 0,
NoticePadding: 0
NoticePadding: 0,
imgArr : [],
},
ready() {
console.log("notice---ready");
let { noticeList, singleImage } = this.data.datas.componentData
singleImage = DFSImg(singleImage)
for (let i = 0; i < noticeList.length; i++) {
......@@ -41,6 +43,17 @@ Component({
* 组件的方法列表
*/
methods: {
bindload(e) {
let { imageWidth } = this.data.datas.componentData;
let index = e.currentTarget.dataset.index;
let width = e.detail.width
let height = e.detail.height
let useHeight = imageWidth / width * height;
this.setData({
[`imgArr[${index}].height`]: useHeight,
})
},
onclickHandle(e) {
let item = this.data.datas.componentData.noticeList[e.currentTarget.dataset.index]
app.trackCpn(e, this.data.datas.componentName, item)
......
......@@ -5,7 +5,7 @@
<view class="container" bindtap="onclickHandle" data-index="{{index}}" style="width: 100%;height:{{CommonHeight}}">
<block wx:if="{{item.imageUrl||datas.componentData.singleImage}}">
<view wx:if="{{datas.componentData.styleType===1}}">
<image class="notice-icon" mode="widthFix" style="width:{{datas.componentData.imageWidth}}px !important;" src="{{item.imageUrl}}" />
<image class="notice-icon" style="width:{{datas.componentData.imageWidth}}px !important; height: {{imgArr[index].height}}px" src="{{item.imageUrl}}" bindload="bindload" data-index="{{index}}" />
</view>
<view wx:else>
<image class="notice-icon" mode="widthFix" style="width:{{datas.componentData.imageWidth}}px !important;" src="{{singleImg}}" />
......
......@@ -31,8 +31,12 @@ VantComponent({
sticky: Boolean,
border: Boolean,
swipeable: Boolean,
titleActiveColor: String,
titleInactiveColor: String,
titleActiveColor: {
type: [String, null]
},
titleInactiveColor: {
type: [String, null]
},
color: String,
datas: Object,
animated: {
......@@ -49,7 +53,6 @@ VantComponent({
// observer: "resize"
},
lineLengthType: {
type: [String, Number],
value: 1 // 1默认自适应 2短自适应 3 固定宽度取值lineWidth
},
linePosition: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment