【问题标题】:Vuesjs Getting v-for length of an ArrayVue Js获取数组的v-for长度
【发布时间】:2020-10-25 07:54:50
【问题描述】:

我想在 VueJs 上渲染 totalCount

这是我的 Grapql Api

query{
  allStudents{
    totalCount
    edges{
      node{
        id
        lastName
        email
      }
    }
  }
}

这里是示例 HTML 代码

  <div>
                <p class="card-text text-right">Total Students</p>
                <div class="fluid-container">
                  <h3 class="card-title font-weight-bold text-right mb-0" v-for="(value, totalCount) in Objects"> {{totalCount}}: {{value}} </h3>
                </div>
              </div>
            </div>

【问题讨论】:

    标签: vue.js graphql


    【解决方案1】:

    这解决了{{ directory.totalCount }}

    【讨论】:

      【解决方案2】:

      在 vue 中可以通过 this.directory.totalCount 访问该属性,在 html 中可以通过 {{this.directory.totalCount}} 访问。

      <div>
          <p class="card-text text-right">Total Students</p>
          <div class="fluid-container">
              <h3 class="card-title font-weight-bold text-right mb-0"
                 v-for="(value, totalCount) in Objects"> 
                   {{directory.totalCount}}: {{value}}
              </h3>
          </div>
      </div>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-13
        • 2022-11-13
        • 1970-01-01
        • 2020-03-29
        • 2020-05-27
        • 1970-01-01
        • 2018-11-16
        • 1970-01-01
        相关资源
        最近更新 更多