Home  >  Q&A  >  body text

How to avoid adding class="" to the last element of a Vue.js loop

<p>In vuejs template, remove tailwind class when looping the last iteration of index. </p> <p><strong>In template</strong></p> <pre class="brush:php;toolbar:false;">v-for="(service, index) in getAllServices.home_page_services" :key="index"</pre> <p><strong>In script</strong></p> <pre class="brush:php;toolbar:false;"><script> export default { mounted() { this.$store.dispatch("getHomePageContent") }, computed: { getAllServices(){ return this.$store.getters.getContentFormGetters } } }</pre></p>
P粉868586032P粉868586032416 days ago470

reply all(1)I'll reply

  • P粉949848849

    P粉9498488492023-08-30 10:00:49

    i can solve it

    :class="{ 'lg:border-r-2 lg:border-blue-650': index < getAllServices.home_page_services.length - 1 }"

    reply
    0
  • Cancelreply