效果如下图:
html部分:
<view class='imgCon'>
<image src='{ {goods.goodsPhotoUrl}}' bindload='imgLoad' style='width:{ {width}}rpx;height:{ {height}}rpx;' ></image><!-- 改动态对应的商品图 -->
</view>
css部分:(css这样设置虽然可以垂直居中,水平居中,但是图片是变形的,所以需要用到js来修改图片宽高)
.imgCon{
width: 160rpx;
height: 160rpx;
display: inline-block;
vertical-align: top;
margin-right: 20rpx;
overflow: hidden;
position: relative;
}
.imgCon image{