javascript 在vue中排序和筛选

jogvjijk  于 2022-10-30  发布在  Java
关注(0)|答案(1)|浏览(122)

我试图排序的JSON数据导入,但它不工作,我想排序它的每日,每周,每月点击在VUE。我想它是排序点击每日,每周,每月。请任何人我会很感激这一切
'这是HTML部分

<template>
 <div class="duration">
          <p 
          v-for="(item, index) in filter When"
          :key="index"
          @click="when = item; active=index ">{{item}}</p>
        </div>
      </div>
      <div 
        class="work box" 
        v-for="(period, index) in moments"

        :item="period"
        :key="index">
        <div>
        <div class="img">
          <img class="icon" src="../assets/images/icon-work.svg" alt="" />
        </div>
        <div class="details xo">
          <div class="header">
            <h5 class="schedule">{{period.title}}</h5>
            <span class="un">…</span>
          </div>
          <div class="moment">
              <p class="hrs">{{period.timeframes.daily.current}}hrs</p>
              <p class="when">Yesterday-<span class="days">{{period.timeframes.daily.previous}}days</span></p>
          </div>
</div>
</template>

`
这是JSON数据

[
  {
    "title": "Work",
    "timeframes": {
      "daily": {
        "current": 5,
        "previous": 7
      },
      "weekly": {
        "current": 32,
        "previous": 36
      },
      "monthly": {
        "current": 103,
        "previous": 128
      }
    }
  },
  {
    "title": "Play",
    "timeframes": {
      "daily": {
        "current": 1,
        "previous": 2
      },
      "weekly": {
        "current": 10,
        "previous": 8
      },
      "monthly": {
        "current": 23,
        "previous": 29
      }
    }
  },

]
bqf10yzr

bqf10yzr1#

我尝试在javascript中过滤器不工作。

相关问题