0

I want to display my string on multiple lines. I already tried something like replaceAll(",", "\n") Here's my Code:

<template>
    <v-form>
        <v-container>
          <v-card
              class="mt-15 pa-4  mx-auto"
              max-width="1000"
              multi-line>
            {{consoleOutput.toString().replaceAll(",", "\n")}}
          </v-card>
        </v-container>
    </v-form>
</template>

<script>
    export default {
        data: () => ({
            consoleOutput: ["This", "should", "be", "on a ", "new Line "],
        })
    }
</script>

I get this output This should be on a new Line. My target is to print each string on a different line and add a index in front of it (equal to console) like:

1. This
2. should
3. be 
4. on a 
5. new Line
Filip Seman
  • 1,252
  • 2
  • 15
  • 22
Volnick
  • 89
  • 8

2 Answers2

3

Try to use ol element and v-for to render each li

 <v-card
    class="mt-15 pa-4  mx-auto"
    max-width="1000"
    multi-line
>
    <ol>
        <li v-for="item in consoleOutput" :key="item">{{item}}</li>
    </ol>
</v-card>
Filip Seman
  • 1,252
  • 2
  • 15
  • 22
Boussadjra Brahim
  • 82,684
  • 19
  • 144
  • 164
1

I think you can do like this.

 <v-container>
  <v-card
      class="mt-15 pa-4  mx-auto"
      max-width="1000"
      multi-line>
      <div v-for="item in consoleOutput.toString().split(',')" :key="item">        
        {{item}}
      </div>
  </v-card>
</v-container>

Please confirm this URL. https://stackblitz.com/edit/vue-gmadqd?file=src%2Fcomponents%2FHelloWorld.vue

BTSM
  • 1,585
  • 8
  • 12
  • 26