您當前位置>首頁 » 新聞資(zī)訊 » 小程序相關(guān) >
微信小程序啟動(dòng)頁的實現
發表時間:2021-1-5
發布人:葵宇科技
浏覽次數:28
将啟動(dòng)頁路(lù)徑放在pages數組的第一項,tabBar中(zhōng)list正常放置。
for='{{testList}}' wx:for-item="item" wx:key="item">
<image src="{{item.fileID}}" bindload="autoImage" style="width:{{imgWidth}};height:{{ imgHeight }}" />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',
});},