O
O
ordinary_pavel2017-03-24 09:48:25
Bootstrap
ordinary_pavel, 2017-03-24 09:48:25

How to recalculate the number of bootstrap columns in vue?

Hello. There is a grid of several blocks (employees of the company). By default in the template, 3 employees are divided by col-sm-4. How to dynamically change the number of columns based on the number of employees using vue?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Khokhlov, 2017-03-24
@ordinary_pavel

<div class="row">
  <div v-for="user in users" v-bind:class="userClass">></div >
</div >

const vm = new Vue({
  el: '#app',
  data: {
    users: [],
  },
  computed: {
    userClass() {
      // ваша логика разделения по колонкам
      return this.users.length > 3 ?  'col-sm-4' :  'col-sm-12';
    },
  },
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question