Home > Blockchain >  How to replace "read more" into vuetify icon in Vue.js?
How to replace "read more" into vuetify icon in Vue.js?

Time:10-28

I'm trying to create photo and description shown below.

How to replace the "read more" and "read less" with arrow icon(up and down)?

<template>
  <v-col cols="6" >
    <row align="center" justify="center">
      <div id="app" >
          <p>A simple Read More, Read Less pen in Vue.js</p>
        
          <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Venenatis lectus magna
            fringilla urna. Etiam tempor orci eu lobortis. Integer quis auctor elit sed vulputate mi sit. Lacinia
            at quis risus sed vulputate odio ut enim blandit. Nibh praesent tristique magna sit amet purus. Eleifend donec pretium vulputate sapien nec
            sagittis. Facilisi morbi tempus iaculis urna id volutpat. Ultrices neque ornare aenean euismod.<span v-if="readMore"></span>
            <span v-else>...</span>
          </p>
        
          <p v-show="readMore">Ligula ullamcorper malesuada proin libero nunc consequat interdum varius. Turpis egestas pretium aenean pharetra magna ac
            placerat. Sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec. Sed cras ornare arcu dui. Aliquam vestibulum
            morbi blandit cursus. Adipiscing elit ut aliquam purus sit amet. Aenean sed adipiscing diam donec adipiscing tristique risus nec. Ut etiam sit amet
            nisl purus in mollis. Eu mi bibendum neque egestas congue quisque egestas diam in. Pellentesque adipiscing
            commodo elit at imperdiet dui accumsan sit.
          </p>
          <button  @click="readMore =! readMore">
            <span v-if="readMore">Read Less</span>
            <span v-else>Read More</span>
          </button>
      </div>
    </row>
  </v-col>
</v-col>

Here is the boolean

<script>
  data() {
    readMore: false
  }
</script>

CodePudding user response:

Just use the v-icon component that wraps the icon name :

<v-icon v-if="readMore"> mdi-arrow-down </v-icon>
<v-icon v-else> mdi-arrow-up </v-icon>
  • Related