- 图片加载顺序问题
在进行瀑布流布局的时候,需要根据图片的高度进行瀑布流布局,另外一个需求是根据浏览量进行从左到右显示,服务器发送的是根据流量排好序的数据,但是我用bindload方法监听图片的加载情况,但是它不是按照服务器给的数据进行加载的导致,瀑布流的浏览量发生错乱,请问有没有好的方法按序加载 [代码]<[代码][代码]view[代码] [代码]style[代码][代码]=[代码][代码]"display:none"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:for[代码][代码]=[代码][代码]"{{newAddEssays}}"[代码] [代码]wx:key[代码][代码]=[代码][代码]'d'[代码][代码]>[代码][代码] [代码][代码]<!--商铺文章-->[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:if[代码][代码]=[代码][代码]'{{item.shopessayhead}}'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:if[代码][代码]=[代码][代码]'{{item.shopessaycustom === 1 && item.shopessaycustomhead !==""}}'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]wx:key[代码][代码]=[代码][代码]"id"[代码] [代码]id[代码][代码]=[代码][代码]"{{item.shopeid}}-{{index}}"[代码] [代码]src[代码][代码]=[代码][代码]"{{imgHost}}{{item.shopessaycustomhead}}"[代码] [代码]bindload[代码][代码]=[代码][代码]"onImageLoad"[代码] [代码]data-last[代码][代码]=[代码][代码]'{{index === (newAddEssays.length - 1) ? true : false}}'[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:else>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]wx:key[代码][代码]=[代码][代码]"id"[代码] [代码]id[代码][代码]=[代码][代码]"{{item.shopeid}}-{{index}}"[代码] [代码]src[代码][代码]=[代码][代码]"{{imgHost}}{{item.shopessayhead[0]}}"[代码] [代码]bindload[代码][代码]=[代码][代码]"onImageLoad"[代码] [代码]data-last[代码][代码]=[代码][代码]'{{index === (newAddEssays.length - 1) ? true : false}}'[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]<!--商品-->[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:if[代码][代码]=[代码][代码]'{{item.head}}'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:if[代码][代码]=[代码][代码]'{{item.custom === 1 && item.customhead !==""}}'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]wx:key[代码][代码]=[代码][代码]"id"[代码] [代码]id[代码][代码]=[代码][代码]"{{item.pid}}-{{index}}"[代码] [代码]src[代码][代码]=[代码][代码]"{{imgHost}}{{item.customhead}}"[代码] [代码]bindload[代码][代码]=[代码][代码]"onImageLoad"[代码] [代码]data-last[代码][代码]=[代码][代码]'{{index === (newAddEssays.length - 1) ? true : false}}'[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:else>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]wx:key[代码][代码]=[代码][代码]"id"[代码] [代码]id[代码][代码]=[代码][代码]"{{item.pid}}-{{index}}"[代码] [代码]src[代码][代码]=[代码][代码]"{{imgHost}}{{item.head[0]}}"[代码] [代码]bindload[代码][代码]=[代码][代码]"onImageLoad"[代码] [代码]data-last[代码][代码]=[代码][代码]'{{index === (newAddEssays.length - 1) ? true : false}}'[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:if[代码][代码]=[代码][代码]'{{item.essayhead}}'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:if[代码][代码]=[代码][代码]'{{item.essaycustom === 1 && item.essaycustomhead !==""}}'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]wx:key[代码][代码]=[代码][代码]"id"[代码] [代码]id[代码][代码]=[代码][代码]"{{item.eid}}-{{index}}"[代码] [代码]src[代码][代码]=[代码][代码]"{{imgHost}}{{item.essaycustomhead}}"[代码] [代码]bindload[代码][代码]=[代码][代码]"onImageLoad"[代码] [代码]data-last[代码][代码]=[代码][代码]'{{index === (newAddEssays.length - 1) ? true : false}}'[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:else>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]wx:key[代码][代码]=[代码][代码]"id"[代码] [代码]id[代码][代码]=[代码][代码]"{{item.eid}}-{{index}}"[代码] [代码]src[代码][代码]=[代码][代码]"{{imgHost}}{{item.essayhead[0]}}"[代码] [代码]bindload[代码][代码]=[代码][代码]"onImageLoad"[代码] [代码]data-last[代码][代码]=[代码][代码]'{{index === (newAddEssays.length - 1) ? true : false}}'[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码]onImageLoad: async [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]let isLast = e.currentTarget.dataset.last;[代码][代码] [代码][代码]console.log([代码][代码]"isLast is "[代码][代码], isLast);[代码][代码] [代码][代码]let imageId = Number(e.currentTarget.id.split([代码][代码]'-'[代码][代码])[0]);[代码][代码] [代码][代码]let imageIndex = Number(e.currentTarget.id.split([代码][代码]'-'[代码][代码])[1]);[代码][代码] [代码][代码]console.log([代码][代码]"imageIndex is "[代码][代码],imageIndex);[代码][代码] [代码][代码]let oImgW = e.detail.width; [代码][代码]//图片原始宽度[代码][代码] [代码][代码]let oImgH = e.detail.height; [代码][代码]//图片原始高度[代码][代码] [代码][代码]let imgWidth = [代码][代码]this[代码][代码].data.imageWidth; [代码][代码]//图片设置的宽度[代码][代码] [代码][代码]let scale = imgWidth / oImgW; [代码][代码]//比例计算[代码][代码] [代码][代码]let imgHeight = oImgH * scale; [代码][代码]//自适应高度[代码][代码] [代码][代码]//新请求的文章数据[代码][代码] [代码][代码]let images = [代码][代码]this[代码][代码].data.newAddEssays;[代码][代码] [代码][代码]let imageLen = images.length;[代码][代码] [代码][代码]let imageObj = [代码][代码]null[代码][代码];[代码][代码] [代码][代码]for[代码] [代码](let i = 0; i < imageLen; i++) {[代码][代码] [代码][代码]let img = images[i];[代码][代码] [代码][代码]if[代码] [代码](img.shopeid && img.shopeid === imageId) {[代码][代码] [代码][代码]imageObj = img;[代码][代码] [代码][代码]break[代码][代码];[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]if[代码] [代码](img.pid && img.pid === imageId) {[代码][代码] [代码][代码]imageObj = img;[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]if[代码] [代码](img.eid && img.eid === imageId) {[代码][代码] [代码][代码]imageObj = img;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码][代码](imageObj !== [代码][代码]null[代码][代码]){[代码][代码] [代码][代码]imageObj.height = imgHeight;[代码][代码] [代码][代码]//记录下该图片是第几个被加载的[代码][代码] [代码][代码]imageObj.index = imageIndex;[代码][代码] [代码][代码]console.log([代码][代码]"imageObj is "[代码][代码], imageObj);[代码][代码] [代码][代码]let loadingCount = [代码][代码]this[代码][代码].data.loadingCount - 1;[代码][代码] [代码][代码]let col1 = [代码][代码]this[代码][代码].data.col1;[代码][代码] [代码][代码]let col2 = [代码][代码]this[代码][代码].data.col2;[代码][代码] [代码][代码]//只要第一列的列高度小于第二列就往第一列放,否则往第二列放[代码][代码] [代码][代码]if[代码] [代码]([代码][代码]this[代码][代码].data.col1H <= [代码][代码]this[代码][代码].data.col2H) {[代码][代码] [代码][代码]this[代码][代码].data.col1H += imgHeight;[代码][代码] [代码][代码]col1.push(imageObj);[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]this[代码][代码].data.col2H += imgHeight;[代码][代码] [代码][代码]col2.push(imageObj);[代码][代码] [代码][代码]}[代码][代码] [代码][代码]console.log([代码][代码]"col1 is "[代码][代码], col1);[代码][代码] [代码][代码]console.log([代码][代码]"col1H is "[代码][代码], [代码][代码]this[代码][代码].data.col1H);[代码][代码] [代码][代码]console.log([代码][代码]"col2 is "[代码][代码], col2);[代码][代码] [代码][代码]console.log([代码][代码]"col2H is "[代码][代码], [代码][代码]this[代码][代码].data.col2H);[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]col1H: [代码][代码]this[代码][代码].data.col1H,[代码][代码] [代码][代码]col2H: [代码][代码]this[代码][代码].data.col2H[代码][代码] [代码][代码]})[代码][代码] [代码][代码]let data = {[代码][代码] [代码][代码]loadingCount: loadingCount,[代码][代码] [代码][代码]col1: col1,[代码][代码] [代码][代码]col2: col2,[代码][代码] [代码][代码]loadOver: [代码][代码]true[代码][代码] [代码][代码]};[代码][代码] [代码][代码]if[代码] [代码](!loadingCount) {[代码][代码] [代码][代码]data.images = [];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]await [代码][代码]this[代码][代码].setData(data, () => {[代码][代码] [代码][代码]wx.hideLoading();[代码][代码] [代码][代码]});[代码][代码] [代码][代码]if[代码] [代码](isLast) {[代码][代码] [代码][代码]console.log([代码][代码]"col1 is "[代码][代码], col1);[代码][代码] [代码][代码]console.log([代码][代码]"col2 is "[代码][代码], col2);[代码][代码] [代码][代码]//渲染完图片之后将新加的文章添加到文章列表中去[代码][代码] [代码][代码]// this.data.dataArray.push(...this.data.newAddEssays);[代码][代码] [代码][代码]//对col1的每个元素进行排序和col2的每个元素进行排序[代码][代码] [代码][代码]// this.setData({[代码][代码] [代码][代码]// col1 : this.data.col1,[代码][代码] [代码][代码]// col2 : this.data.col2,[代码][代码] [代码][代码]// loadOver : true[代码][代码] [代码][代码]// },()=>{[代码][代码] [代码][代码]// wx.hideLoading();[代码][代码] [代码][代码]// })[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码]
2018-12-21 - onReachBottom问题
当点击一个按钮的时候,page的高度是一个值,当点击另外一个按钮的时候,page的高度是另外一个值,有时候会触发onReachBottom,有时候不会触发onReachBottom
2018-12-18 - bindtouchstart和bindtouchend 及bindtap事件
想问一下点击内部item view怎么样触发内部的事件,外部的事件不会触发事件,滑动外部的view会触发相应事件,内部的事件不会触发 <view class='wrap' bindtouchstart='start' bindtouchend='end'> <view class='stag'> <view class='item' catchtap='click'></view> </view> </view>
2018-12-04 - 微信小程序css动画问题
微信小程序做动画的时候怎样获得当前的位置属性,比如 :left ,top scale 获取到这些属性后就可以进行根据之前的位置进行变换, 类似这样: [代码]@keyframes moveLeft{[代码][代码] [代码][代码]from{[代码][代码] [代码] [代码] [代码][代码]}to{[代码][代码] [代码][代码]left: -100rpx;[代码][代码] [代码][代码]top: -5%;[代码][代码] [代码][代码]}[代码][代码]}[代码]现在就是不知道当前的位置属性是怎样的,这个from设置成空的话就会直接变换到-100的位置,我是想让它每次向左移动一定距离,向上移动一定的距离,然后在将scale值加上0.1。请问这该如何实现啊。
2018-11-24 - 微信小程序3d轮播图加旋转动画
[图片] 请问这样的轮播图加滑动是的动画显示怎么做呢,加上轮播图组件就会没有3d效果,自己写逻辑css动画那块优点问题不能动态修改class名
2018-11-22