3

Basically the code works fine but I am not able to change the order of the elements.
At the moment the result looks like this:

enter image description here

But actually I would like it like this:

enter image description here

My code Looks like this:

<template>
  <div class="home">
    <el-container>
      <el-row v-for="story of chunkedItems" :key="story.id">
        <el-col v-for="item of story" :key="item.id">
          <el-card>
            <div>{{ item.title }}</div>
            <div>{{ item.text }}</div>
          </el-card>
        </el-col>
      </el-row>
    </el-container>
  </div>
</template>

computed: {
    chunkedItems() {
      return this.$_.chunk(this.stories, 3);
    },
  },

Any suggestion is appreciated.

1
  • Maybe it can be done by CSS el-container { display: flex; flex-direction: row; } Commented Jan 9, 2021 at 11:51

1 Answer 1

3

Remove the chunk and use :span="8" instead.

<template>
  <div class="home">
    <el-container>
      <el-row>
        <el-col :span="8" v-for="item of stories" :key="item.id">
          <el-card>
            <div>{{ item.title }}</div>
            <div>{{ item.text }}</div>
          </el-card>
        </el-col>
      </el-row>
    </el-container>
  </div>
</template>

computed: {
},
Sign up to request clarification or add additional context in comments.

2 Comments

Worked like a charm. Thank you! Obviously I did not understand the span attribute too well.
np, is in the docs 3/24 = 8, if you want weird cols like your example use modulo :span="index % 2 == 0 ? 12:3" v-for="(item, index) in stories"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.