Skip to content

微信小程序wxs

微信小程序wxml中没有办法使用一些必要的逻辑运算,逻辑运算依赖于wxs实现内嵌

比如对时间进行简单的分割

html
<wxs module="func">
  // 用于处理切割时间
  module.exports = {
    getGroupMonth: function (str) {
      str = str.split('月')[0]
      if (str) {
        return str;
      }
      return ''
    },
    getGroupOther: function (str) {
      str = str.split('月')[1]
      if (str) {
        return '月' + str;
      }
      return ''
    }
  }
</wxs>

<text style="font-weight: 600; font-size: 72rpx;margin-right: 10rpx;" class="flow-time-month">{{func.getGroupMonth(item.groupMonth)}}</text>
<text class="flow-time-other">{{func.getGroupOther(item.groupMonth)}}</text>

鄂ICP备19018246号-1