网络编程 
首页 > 网络编程 > 浏览文章

超简单的微信小程序轮播图

(编辑:jimmy 日期: 2024/5/8 浏览:3 次 )

Tips:微信小程序可以在HbuilderX用HTML标签(如Ddiv、span等)写前端代码,也可以用微信小程序语法写(view、swiper标签),然后npm run dev编译后,在微信开发者工具里面导入该项目,就可以调试项目,查看效果。

效果图:

超简单的微信小程序轮播图

微信小程序实现轮播图,本例是在*.wpy页面开发(该页面的temlate内容对应小程序的wxml,style样式对应小程序的wxss,script对应小程序的js文件,config对应小程序的json文件)

<style type="less" scoped="scoped">
  .swiper image {
   width: 100%;
   height: auto;
 }
 
  .swiper-image {
   height: 100%;
   width: 100%;
  }
 
  .slide-image {
   height: 100%;
   width: 100%;
   display: block;
  }
</style>
<template>
   <view class="swiper">
    <swiper indicator-dots="{{indicatorDots}}" vertical="{{vertical}}" autoplay="{{autoplay}}" duration="{{duration}}" interval="{{interval}}" indicator-active-color="#007aff" bindchange="bindchange" circular="{{circular}}"
      style="height:{{imgheights[current]}}rpx;">
      <block wx:for="{{GoodsDatas.imgshow}}" wx:for-key="{{index}}" wx:for-item="image">
        <swiper-item>
          <image src="/UploadFiles/2021-04-02/{{image.img}}">

将代码粘过去之后,只需要修改循环对象为图片数据就可以了。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

上一篇:Vue混入mixins滚动触底的方法
下一篇:微信小程序实现Swiper轮播图效果
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网