【问题标题】:How to populate bootstrap grid dynamically using Vue.js如何使用 Vue.js 动态填充引导网格
【发布时间】:2020-09-16 04:53:51
【问题描述】:

到目前为止,我已经从我的数据库中获取了一个对象列表(每个对象都包含一个名称和描述),并希望在引导网格中显示这些对象,以便每个对象都有自己的部分,并显示其名称和描述。因此,例如,如果列表中有 5 个项目,我希望每行 3 个项目,那么它看起来像这样:

网格会响应屏幕尺寸。 我对 Vue 不是很熟悉,如果不对网格进行硬编码,我看不到如何做到这一点。

这是我的代码目前的样子:

<template>
  <div class="app">
  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'app2',
  data() {
    return {
      items: []
    }
  },
// Fetch items from database...
}

【问题讨论】:

标签: vue.js bootstrap-4


【解决方案1】:

使用 v-for 和 bootstrap 样式:

<template>
  <div class="app">

    <div class="row">
      <div class="col-sm" v-for="item in items">
        {{ item.prop1 }}
      </div>
    </div>

  </div>
</template>

<script>
import axios from 'axios'
export default {
  name: 'app2',
  data() {
    return {
      items: []
    }
  },
// Fetch items from database...
}

【讨论】:

    猜你喜欢
    • 2018-07-03
    • 2019-04-15
    • 2017-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多