- scroll-view使用了动态高度,自定义刷新拉不下来?
//这里的高度是我自定义减去导航栏高度,只要使用了{{titleHeight}},刷新就拉不下来,该怎么解决?求大佬告知 <scroll-view scroll-y style="width: 100%; height: calc(100% - 88rpx - {{titleHeight}}px)" refresher-enabled="{{true}}" refresher-threshold="{{100}}" refresher-default-style="white" refresher-background="lightgreen" refresher-triggered="{{triggered}}" bindrefresherpulling="onPulling" bindrefresherrefresh="onRefresh" bindrefresherrestore="onRestore" bindrefresherabort="onAbort" > <view wx:for="{{arr}}" style="display: flex; height: 100px;"> <image src="https://images.unsplash.com/photo-1565699894576-1710004524ba?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1832&q=80"></image> <image src="https://images.unsplash.com/photo-1566402441483-c959946717ed?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1600&q=80"></image> <image src="https://images.unsplash.com/photo-1566378955258-7633cb5c823e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=634&q=80"></image> <image src="https://images.unsplash.com/photo-1566404394190-cda8c6209208?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=630&q=80"></image> <image src="https://images.unsplash.com/photo-1566490595448-be523b4d2914?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=958&q=80"></image> </view> </scroll-view>
2020-04-09 - wx.createSelectorQuery()异步问题?研究两天了。求大佬说一下
wxml代码: <scroll-view scroll-x="true" scroll-with-animation class="horizontal" scroll-left="{{scroll}}" id="horizontal"> <view class="tabs"> <view class="tab {{active==index?'activeTab':''}}" wx:for="{{list}}" wx:key="index" bindtap="getItem" data-index="{{index}}" id="item-{{index}}">{{item.name}}</view> <view class='line' id="line" style="left:{{list[active].offsetLeft}}px;width:{{list[active].width}}px;"></view> </view> </scroll-view> js部分 data: { list: [{ id: "0", name: "测试" }, { id: "0", name: "测试测试" }, { id: "0", name: "测试测试测试" }, ], } 传入list给list增加offsetLeft和width属性 initItem(e) { return new Promise((resolve, reject) => { e.forEach((item, index) => { let view = wx.createSelectorQuery().select("#item-" + index) view.boundingClientRect(res => { item.offsetLeft = res.left item.width = res.width }).exec() }) resolve(e) }) }, 在生命周期onReady初始化打印res可以,res[0]就不行,昨天我问了下是异步问题,所以加了promise,但是.then还是打印res[0]为未定义。求大佬解决 万分感谢 this.initItem(this.data.list).then(res=>{ console.log(res) console.log(res[0]) })
2020-02-19 - console.log打印为空。数组明明有该数据?
[图片]
2020-02-18