当前位置:网站首页>微信小程序轮播图的代码错误写法

微信小程序轮播图的代码错误写法

2022-06-09 14:05:00 hamimelon2020

<view class="tupian">
  <swiper>
    <swiper-item>
      <image src="{
    {}}"></image>
    </swiper-item>
  </swiper>
</view>
<view class="tupian">
  <swiper indicator-dots="{
    {indicatorDots}}" 
          autoplay="{
    {autoplay}}" 
          interval="{
    {interval}}"
          duration="{
    {duration}}">
            <block wx:for="{
    {background}}" wx:key="*this">
              <swiper-item>
                <image src="{
    {}}"></image>
              </swiper-item>
            </block>
  </swiper>
</view>

view class="tupian">
  <swiper indicator-dots="true" 
          autoplay="true" 
          interval="2000">
            <block wx:for="{
    {coverList}}" wx:key="id" bindtap="goodsbug">
              <swiper-item>
                <image class="photo" src="{
    {item.url}}"></image>
              </swiper-item>
            </block>
  </swiper>
</view>


.tupian {
    
  width: 100%;
  height: 100%;
  line-height: 10px;
}


// pages/index_hio/index_hio.js
Page({
    

  /** * 页面的初始数据 */
  data: {
    
    centerItem: 0,
    coverList: [
      {
    
      id: 0,
      url: "../image/photo/1.jpeg"
    },
    {
    
      id: 1,
      url: "../image/photo/2.jpeg"
    },
    {
    
      id: 2,
      url: "../image/photo/3.jpeg"
    },
    {
    
      id: 3,
      url: "../image/photo/4.jpeg"
    }
    ]
  },

  /** * 生命周期函数--监听页面加载 */
  onLoad(options) {
    

  },

  /** * 生命周期函数--监听页面初次渲染完成 */
  onReady() {
    

  },

  /** * 生命周期函数--监听页面显示 */
  onShow() {
    

  },

  /** * 生命周期函数--监听页面隐藏 */
  onHide() {
    

  },

  /** * 生命周期函数--监听页面卸载 */
  onUnload() {
    

  },

  /** * 页面相关事件处理函数--监听用户下拉动作 */
  onPullDownRefresh() {
    

  },

  /** * 页面上拉触底事件的处理函数 */
  onReachBottom() {
    

  },

  /** * 用户点击右上角分享 */
  onShareAppMessage() {
    

  }
})
原网站

版权声明
本文为[hamimelon2020]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_40945354/article/details/125197300