將啓動頁路徑放在pages數組的第一項,tabBar中list正常放置。
javascript
<view wx:for='{{testList}}' wx:for-item="item" wx:key="item"> <image src="{{item.fileID}}" bindload="autoImage" style="width:{{imgWidth}};height:{{ imgHeight }}" /></view>
<view class="userinfo"> <view class="userinfo-avatar"> <open-data type="userAvatarUrl"></open-data> </view> <view class="userinfo-name"> <text>{{msg}}</text> <open-data type="userNickName"></open-data> </view> <button hover-class="btn_red" class="btn" bindtap="goToIndex">進入店鋪</button> </view>
autoImage(e) { var that = this; var originalWidth = e.detail.width; var originalHeight = e.detail.height; var imageWidth = 0; var imageHeight = 0; wx.getSystemInfo({ complete: (res) => { var winWidth = res.windowWidth; if (originalWidth > winWidth) { var autoWidth = winWidth; var autoHeight = (autoWidth * originalHeight) / originalWidth; imageWidth = autoWidth + 'px'; imageHeight = autoHeight + 'px'; } else { imageWidth = originalWidth + 'px'; imageHeight = originalHeight + 'px'; } that.setData({ imgWidth: imageWidth, imgHeight: imageHeight }); } })},
goToIndex() { wx.switchTab({ url: '/pages/index/index', });},
本文分享自微信公衆號 - 前端一塊兒學(gh_3ba18d51f982)。
若有侵權,請聯繫 support@oschina.cn 刪除。
本文參與「OSC源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。前端