windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server https://softhier.com/ instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

is there a way to break list into columns using VueJs?

Asked By: Anonymous

I have a List which is being rendered using v-for and i am outputting the data into one column. Is there a way that after a certain width and height, the data flows into next column without making any new Array? Here is a demo.

_x000D_

_x000D_

new Vue({_x000D_
  el: '#app',_x000D_
  data() {_x000D_
    return {_x000D_
      lists: [{_x000D_
          text: 'Item1'_x000D_
        },_x000D_
        {_x000D_
          text: 'Item2'_x000D_
        },_x000D_
        {_x000D_
          text: 'Item3'_x000D_
        },_x000D_
        {_x000D_
          text: 'Item4'_x000D_
        },_x000D_
        {_x000D_
          text: 'Item5'_x000D_
        },_x000D_
        {_x000D_
          text: 'Item6'_x000D_
        },_x000D_
        {_x000D_
          text: 'Item7'_x000D_
        },_x000D_
        {_x000D_
          text: 'Item8'_x000D_
        },_x000D_
        {_x000D_
          text: 'Item9'_x000D_
        },_x000D_
      ]_x000D_
    }_x000D_
  }_x000D_
})

_x000D_

<a href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.js">https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.js</a>_x000D_
<a href="https://cdn.jsdelivr.net/npm/vue/dist/vue.js">https://cdn.jsdelivr.net/npm/vue/dist/vue.js</a>_x000D_
<a href="https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js">https://cdn.jsdelivr.net/npm/babel-polyfill/dist/polyfill.min.js</a>_x000D_
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/vuetify.min.css" rel="stylesheet" />_x000D_
<div id="app">_x000D_
  <v-app id="inspire">_x000D_
    <v-layout class="mt-3 ml-4">_x000D_
      <v-flex md-4>_x000D_
        <div v-for="list in lists" :key="list.text">_x000D_
          {{list.text}}_x000D_
        </div>_x000D_
      </v-flex>_x000D_
      <v-flex md4>_x000D_
        //After a certain width and height, make data flow into this column?_x000D_
      </v-flex>_x000D_
    </v-layout>_x000D_
  </v-app>_x000D_
</div>

_x000D_

_x000D_

x000D

I prefer to use widths and heights instead of creating a new Array just so that i don’t have to lot of manual adjustments throughout the code to deal with the new array.


Solution

Answered By: Anonymous

You can use CSS to easily create columns. Just use a v-for to get the content on the screen then style it with CSS. In your case the loop will append multiple <div> elements. Here’s an example of CSS columns.

This is the most basic solution where column-count: 3 splits the list into 3 equal columns.

_x000D_

_x000D_

.column_wrapper {_x000D_
  column-count: 3;_x000D_
}

_x000D_

<div class="column_wrapper">_x000D_
  <!-- results of <div v-for="item in list"></div>  -->_x000D_
  <div>Item 1</div>_x000D_
  <div>Item 2</div>_x000D_
  <div>Item 3</div>_x000D_
  <div>Item 4</div>_x000D_
  <div>Item 5</div>_x000D_
  <div>Item 6</div>_x000D_
  <div>Item 7</div>_x000D_
  <div>Item 8</div>_x000D_
  <div>Item 9</div>_x000D_
  <div>Item 10</div>_x000D_
  <div>Item 11</div>_x000D_
  <div>Item 12</div>_x000D_
  <div>Item 13</div>_x000D_
  <div>Item 14</div>_x000D_
  <div>Item 15</div>_x000D_
</div>

_x000D_

_x000D_

x000D

The downfall of this solution is that the browser will ALWAYS try to break the list into 3 columns. If you only want the columns to split after a specific height, you can use flex-box

For example (if the list is longer than what fits into 200px tall)

_x000D_

_x000D_

.column_wrapper {_x000D_
    max-height: 200px;_x000D_
    display: flex;_x000D_
    flex-flow: column wrap;_x000D_
}

_x000D_

<div class="column_wrapper">_x000D_
  <!-- results of <div v-for="item in list"></div>  -->_x000D_
  <div>Item 1</div>_x000D_
  <div>Item 2</div>_x000D_
  <div>Item 3</div>_x000D_
  <div>Item 4</div>_x000D_
  <div>Item 5</div>_x000D_
  <div>Item 6</div>_x000D_
  <div>Item 7</div>_x000D_
  <div>Item 8</div>_x000D_
  <div>Item 9</div>_x000D_
  <div>Item 10</div>_x000D_
  <div>Item 11</div>_x000D_
  <div>Item 12</div>_x000D_
  <div>Item 13</div>_x000D_
  <div>Item 14</div>_x000D_
  <div>Item 15</div>_x000D_
</div>

_x000D_

_x000D_

x000D

Note: in both examples the location at which it splits is arbitrary (as in the brower decides when to move to the next column). If you need to decide where it breaks, creating a new array for each column in vue is your best bet.

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort http://www.kadinescort.net Gaziantep escort Denizli escort Adana escort Hatay escort Aydın escort İzmir escort Ankara escort Antalya escort Bursa escort İstanbul escort Kocaeli escort Konya escort Muğla escort Malatya escort Kayseri escort Mersin escort Samsun escort Sinop escort Tekirdağ escort Eskişehir escort Yalova escort Rize escort Amasya escort Balıkesir escort Çanakkale escort Bolu escort Erzincan escort Şırnak escort Van escort Yozgat escort Zonguldak escort Afyon escort Adıyaman escort Bilecik escort Aksaray escort Ağri escort Bitlis escort Siirt escort Çorum escort Burdur escort Diyarbakir escort Edirne escort Düzce escort Erzurum escort Kırklareli escort Giresun escort Kilis escort Kars escort Karabük escort Kırıkkale escort Mardin escort Kırşehir escort Maraş escort Manisa escort Muş escort Kastamonu escort Ordu escort Nevşehir escort Sakarya escort Osmaniye escort Şanliurfa escort Sivas escort Trabzon escort Tokat escort Ardahan escort Bartın escort Karaman escort Batman escort Bayburt escort Bingöl escort Elaziğ escort Gümüşhane escort Hakkari escort Isparta escort Uşak escort Igdır escort