当前位置:首页站长学院后端开发小程序如何在轮播图里面实现点击跳转
企业营销,就选知企PROSAAS

小程序如何在轮播图里面实现点击跳转

小程序如何在轮播图里面实现点击跳转

小程序如何在轮播图里面实现点击跳转

轮播图可以使用swiper组件来实现,点击跳转页面可以使用navigator组件来实现,所以实现点击轮播图跳转页面的方法是:在swiper组件的swiper-item组件里嵌套一个navigator即可。

具体实现代码如下:

1、WXML代码

  <!--轮播图 -->
  <view class='swiperBanner'>
    <swiper indicator-dots='{{indicatorDots}}' autoplay='{{autoplay}}' interval='{{interval}}' duration='{{duration}}' circular='{{circular}}'>
      <swiper-item  wx:for="{{imgUrls}}" wx:key='{{index}}'>
        <navigator url='{{item.link}}'>
          <image src="{{item.url}}" class="slide-image" mode="aspectFill"></image>
        </navigator> 
      </swiper-item>
    </swiper>
  </view>
</view>

2、WXSS代码

/* 轮播 */
.swiperBanner{
  width:100%;
  height:420rpx !important;
  margin:0 auto; 
}
.swiperBanner image{
  width:100%;
  height:420rpx !important;
}
swiper {
  width:100%;
  height:420rpx !important;
}

3、JS代码

indicatorDots:false,
   autoplay:true,
   interval:3000,
   duration: 800,
   circular:true,
    // 轮播图
   imgUrls: [
     {
       link:'../activity/washCar1/index/index',
       url:'https://localhost/static/ttcf/img/banner8.png',
 
     },
     {
       link: '../activity/Odysseus/index/index',
       url: 'https://localhost/static/ttcf/img/banner9.png',
 
     },
 
   ],

PHP中文网,大量免费小程序开发教程,欢迎学习!

以上就是小程序如何在轮播图里面实现点击跳转的详细内容,更多请关注知企PROSAAS其它相关文章!

温馨提示:

文章标题:小程序如何在轮播图里面实现点击跳转

文章链接:https://ceshi.prosaas.cn/16806.html

更新时间:2020年03月25日

声明: 本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:973664285@qq.com我们将第一时间处理! 资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。 所有资源仅限于参考和学习,版权归原作者所有,更多请阅读知企PROSAAS协议

给TA打赏
共{{data.count}}人
人已打赏
后端开发

小程序闪退怎么修复

2020-3-25 11:15:22

后端开发

在小程序中怎样调用本地接口

2020-3-25 11:43:05

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索