02微信小程序-轮播的宽度100%显示和轮播的基础配置

 

复制代码
1==》如何让轮播的宽度100%显示?
你先给swiper 外面添加一个大盒子,给大盒子一个类 。 
<view class='lunbobox'>
然后wxss 里面设置 image , width: 100%; 在设置大盒子的宽度 width: 100%; 这样就可以了.


<view class='lunbobox'>
  <!-- 轮播开始 -->
  <swiper  indicator-dots="{{indicatorDots}}"
  circular
  autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
  <block wx:for="{{imgUrls}}">
    <swiper-item>
      <image src="{{item}}" class="slide-image" width="750" height="150"/>
    </swiper-item>
  </block>
</swiper>
<!-- end -->
</view>

设置盒子的宽度 图片的宽度 让图片100%显示
.lunbobox{
  width: 750rpx;
}

.slide-image{
  width: 100%;
}



2==轮播的基础配置项
   circular表示是否衔接  后面不要加true哦

  <swiper  indicator-dots="{{indicatorDots}}"
  circular
  autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
  <block wx:for="{{imgUrls}}">
    <swiper-item>
      <image src="{{item}}" class="slide-image" width="750" height="150"/>
    </swiper-item>
  </block>
</swiper>

// 轮播
imgUrls: [
  'https://images.unsplash.com/photo-1551334787-21e6bd3ab135?w=750',
  'https://images.unsplash.com/photo-1551214012-84f95e060dee?w=750',
  'https://images.unsplash.com/photo-1551446591-142875a901a1?w=750'
],
indicatorDots: true, //是否显示小圆点  true显示
autoplay: true,     //是否自动播放  true自动播放
interval: 5000,     //播放的间隔
duration: 1000,      //滑 动动画时长


03==》跳转使用 它在导航里面的哦  <navigator></navigator>
navigator标签类似于a标签,它里面是可以包含view标签的


04==》如何循环三个导航链接
ps: wx:for="{{labs}}" 循环的语法 labs是被循环的数组  注意有双引号  item是循环的每一项  

 <navigator url="../list/list" hover-class="navigator-hover" wx:for="{{labs}}">
    <view>{{item.title}}</view>
 </navigator>

// 导航链接的数据
labs: [{ id: 1, title: "haha1" }, { id: 3, title: "haha2" }, { id: 3, title: "haha3" }]

05==》css3 一个在最左最右 /* 导航 */
.daohangbox{
display: flex;
justify-content: space-between; //巧记两者之间 between说明一个在左一个在右
}

复制代码

 

posted @   南风晚来晚相识  阅读(820)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
点击右上角即可分享
微信分享提示