微信小程序3层循环

微信小程序3层循环,第1张

//第一层循环

<view wx:for="{{arr}}" wx:key="index">

    <view>{{item.name}}</view>

    //第二层循环,修改item、index名称

    <view wx:for="{{item.process}}" wx:for-item="itema" wx:for-index="indexa" wx:key="indexa">

        // 判断是哪种结构

        <block wx:if="{{itema.goods_name}}">

            <view>{{itema.goods_name}}</view>

        </block>

        <block wx:else>

            <view>{{itema.type}}</view>

            //第三层判断是否是数组

            <block wx:if="{{itema.state && itema.state[0] && itema.state[0].time}}">

                <view wx:for="{{itema.state}}" wx:for-item="itemb" wx:for-index="indexb" wx:key="indexb">{{itemb.time}}</view>

            </blcok>

            <blcok wx:else>

                <view>{{itema.state}}</view>

            </blcok>

        </block>

    </view>

</view>

swiper组件的常用属性

属性     类型默认值 说明

indicator-dots     boolean false 是否显示面板指示点

indicator-color    color rgba(0,0,0,.3) 指示点颜色

indicator-active-color   color #O000oo 当前选中的指示点颜色

autoplay     boolean false 是否自动切换

interval      number 5000    自动切换时间间隔

circular     boolean false    是否采用衔接滑动`

二、按钮

通过type属性指定按钮颜色类型

<button>普通按钮</button>

<button type="primary">主色调按钮</button>

<button type="warn">警告按钮</button>

size="mini" 小尺寸按钮同一行

<button size="mini">普通按钮</button>

<button type="primary" size="mini">主色调按钮</button>

<button type="warn" size="mini">警告按钮</button>

plain 镂空按钮

<button plain>普通按钮</button>

<button type="primary" plain>主色调按钮</button>

<button type="warn" plain>警告按钮</button>

  data: {

    inputVal : '',

    storageVal:''

  },

  bindkeyInput: function (e) {

    let {detail: { value }  } = e

    this.setData({

      inputVal: value

    })

  },

  cun:function(){

    let arr=['name','age','sex']

    let i =Math.floor(Math.random()*(2-0+1)+0)

    /* 异步取缓存的值必须在回调函数里面取 同的直接=即可 */

    wx.setStorage({

      key:'myname',

      data:'我是小超人',

      success:function(){

        console.log('我成功了')

      }

    })

    /* 同步的存起来 */

    /* 相同的key会把值覆盖 */

    /* wx.setStorageSync('username', this.data.inputVal) */

    wx.setStorageSync(arr[i],this.data.inputVal)

  },

  qu:function(){

    this.setData({

      /* 同步的取缓存的值 */

      /* 浏览器中的缓存存进去的都是字符串,小程序里的缓存可以存字符串,数组和对象 */

      /* undefined存进去是字符串 null存进去是null类型 Symbol存进去是Symbol类型 */

      /* storageVal:wx.getStorageSync('username') */

       storageVal:wx.getStorageSync('sex')

    })

  },

  delSex:function(){

    /* 同步删除指定的某一个缓存 */

    wx.removeStorageSync('sex')

  },

  delAll:function(){

    wx.clearStorageSync()

  },


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12063860.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-20
下一篇2023-05-20

发表评论

登录后才能评论

评论列表(0条)

    保存