1 year ago

Vue.js v-for help!

Posted 1 year ago by joshgallagher24

I have a vue component that spits out a list of articles. I want to apply color classes to these articles.

in the article-item component I have an array of classes:

    data () {
      return {
        titleColors: [

The problem is, i can only add these classes to the first 4 articles that are rendered as the array length is 3.

Is there anyway I can apply these classes to the first 4 articles, and then reset the v-for index?

This is where I am looping through the articles:

<article-item v-for="(article, index) in articles.articles" :article="article" :key="" :index="index" :length="articles.articles.length"></article-item>

Any help would be much appreciated!

Please sign in or create an account to participate in this conversation.