uni-app小程序中swiper图片不显示
程序员文章站
2022-04-29 14:38:41
...
<view class="swiper_img">
<uni-swiper-dot :info="info" :current="current" :mode="mode" field="content">
<swiper class="swiper-box" @change="change" :autoplay="true" :interval="3000" :duration="500">
<swiper-item v-for="(item, index) in info" :key="index">
<view :class="item.colorClass" class="swiper-item">
<image class="image" :src="item.url" mode="aspectFill" />
</view>
</swiper-item>
</swiper>
</uni-swiper-dot>
</view>
info: [{
colorClass: 'uni-bg-red',
url: '/static/1.png',
content: '内容 A'
},
{
colorClass: 'uni-bg-green',
url: '/static/1.png',
content: '内容 B'
}]
1.首先确认自己的路径是否正确
2. 给swiper加宽度和高度
.swiper_img{
height:600rpx;
width: 80%;
display: flex;
justify-content: center;
align-items: center;
margin-top:60rpx;
.swiper-box{//加宽度高度
height:600rpx;
width:600rpx;
}
.image{
width: 100%;
height:600rpx;
}
}
上一篇: PHP性能优化准备篇图解PEAR安装
下一篇: Vue获取DOM元素样式和样式更改