使用的是vant组件模板,之前在wxml写死数据的时候间距正常,尝试wx:for循环后成了这样
之前:
wxml代码:
<van-tabs active="{{ active }}" bind:change="onChange" animated>
<van-tab title="未送达">
<scroll-view scroll-y="true" style="height: 900rpx; margin-top: 45rpx;">
<view class="order_box" style="height: 400px;opacity: 0.85;margin-top:5%;margin-left:16%;margin-bottom: 5%;"
wx:for="{{orderList}}" wx:key="oid">
<van-card
desc="订单号:{{item.oid}}"
title="{{item.oname}}"
num="{{item.count}}"
price="{{item.money}}"
desc-class="cardDesc"
style="margin-bottom: 5%;"
>
<view slot="footer">
<button class="box_btn" bindtap="showDetailDialog" size="mini">详情</button>
<button class="box_btn" size="mini" bindtap="orderReminder">催单</button>
</view>
</van-card>
</view>
</scroll-view>
</van-tab>
<van-tab title="待支付" dot="true">
<scroll-view scroll-y="true" style="height: 400px;">
<view class="order_box" style="height: 400px;opacity: 0.85;margin-top:5%;margin-left:16%;">
<view style="margin-bottom: 5%;">
</view>
</view>
</scroll-view>
</van-tab>
<van-tab title="待评价" dot="true">
<scroll-view scroll-y="true" style="height: 400px;">
<view class="order_box" style="height: 400px;opacity: 0.85;margin-top:5%;margin-left:16%;">
<view style="margin-bottom: 5%;">
</view>
</view>
</scroll-view>
</van-tab>
</van-tabs>
wxss代码:
.van-tab{}
.van-tabs{}
.van-card{
width: 80%;
height: 35%;
border-radius:7px
}
.order_box{
justify-content: center;
height: 20%;
}
.scroll-view{}
.cardDesc{
margin-top: 20rpx;
}
开发者工具不会用吗,检查一下元素啊,是边距导致还是高度导致的,在进行调整
css里
justify-content: center;
这个删了
js的相关代码:
data: {
active: 0,
show: false,
value: 0,
showDetail: false,
showCancel: false,
orderList:[
{
oid:10000001,
oname:"二尺长的龙虾",
money:2.00,
count:1,
ispay:1
},
{
oid:10000002,
oname:"三尺长的龙虾",
money:2.00,
count:1,
ispay:0
},
{
oid:10000003,
oname:"四尺长的龙虾",
money:2.00,
count:1,
ispay:1
}
]
},
getOrderList(){
let that=this;
wx.request({
url: 'url',
method: 'POST',
success(res){
setData:({
orderList:res.data.orderList
})
}
})
},
<button class="add_btn" bindtap="showDialog" style="margin-left: 25%; margin-bottom: 90rpx; opacity: 0.50; filter: alpha(opacity=80);">添加订单</button>
<van-dialog
use-slot
title="添加订单"
show="{{ show }}"
show-cancel-button
bind:close="onClose"
>
<view class="input-container">
<van-cell-group inset class="input-container">
<van-field
label="收件人"
left-icon="user-o"
value="{{ uname }}"
size="large"
focus="{{ true }}"
placeholder="请输入收件人"
border="{{ false }}"
/>
<van-field
label="货物"
left-icon="shopping-cart-o"
value="{{ uname }}"
size="large"
focus="{{ true }}"
placeholder="请输入货物名"
border="{{ false }}"
/>
<van-field
label="配送地"
left-icon="location-o"