Show a string on different lines

I'm looking to format my string so that it displays on multiple lines. I attempted to use replaceAll(",", "\n"), but it didn't work as expected. Here's the code snippet:

<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>

The current output is This should be on a new Line. However, I want each string to be displayed on a separate line with an index in front of it (similar to console). It should look like this:

1. This
2. should
3. be 
4. on a 
5. new Line

Answer №1

Consider using the ol element along with v-for to display each item in a list format.

<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>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Combine the elements of an array to form a cohesive string

As a newcomer to Javascript, I am feeling a bit puzzled about this conversion. var string = ['a','b','c']; into 'a','b','c' ...

Generate a bootstrap component on a template using dynamic rendering

I am looking for a way to dynamically display a bootstrap icon in my template depending on the outcome of a function. Initially, I attempted the following approach: <template> <div> {{ getUsersEmai ...

Guide on generating a dynamic loop in JavaScript using the group name as a variable

I have been attempting to organize a group, dynamically ungroup it, and then create a loop with each element of the group. Despite reviewing multiple examples, I have not been able to solve the following issue: The grouping is done based on the "tipo" pro ...

How can Backbone.js utilize Ajax to bind data to a Collection?

I've recently delved into the world of Backbone.js. My goal is to create a Collection and populate it with data sourced externally. The current format of the data is CSV, not JSON. I am considering converting it to JSON for simplicity. Therefore, I ...

How to connect an external module to NuxtJS using Vue.js

Attempting to incorporate a widget/plugin/extension system into my existing web UI built with NuxtJS. Within the pages/view.vue single-file component, I aim to establish the extension system by dynamically loading components indicated through query paramet ...

The modification of HTML styles

How can I change the style (width, color etc) of all 8 functions like this? function my(){document.getElementById("question1").innerHTML="THIS QUESTION"+ "<br>" +"<button onclick=answer1() id=ques1 >first answer</button>" +"<button ...

What is the best way to incorporate multiple vertical axes (y) into a Google chart?

I created a line graph with 2 lines that refresh every 5 seconds. Now, I'm trying to add dual vAxis on the left and right side. However, I can't seem to display the vAxis title. How can I fix this? Here is the chart option that I added: This ...

In Redux, it is possible to add characters to an array but for some reason the remove action does not successfully reach the reducer

As a user types or erases characters, I am utilizing redux to update an array of characters. This allows me to set a success flag when the user correctly types the entire phrase. Currently, when typing in characters, the SET_INPUT action in redux fires of ...

Extract portions of the date into individual variables

My current project involves creating a front-end interface for data stored in a JSON database. The date information is saved in the following format: 12/31/16 I am trying to extract each of these values individually. Is there a method to assign variabl ...

unable to locate public folder in express.js

I recently created a basic server using Node.js with Express, and configured the public folder to serve static files. Within my main index.js file, I included the following code: const express = require('express'); const app = express(); const h ...

Refreshing a specific div within an HTML page

I am facing an issue with the navigation on my website. Currently, I have a div on the left side of the page containing a nav bar. However, when a user clicks a link in the nav bar, only the content on the right side of the page changes. Is there a way t ...

IE throwing an invalid argument error when making an AJAX request

I have a strange issue with my ajax request - it works perfectly fine in all browsers except for IE, specifically IE10! The error message I am encountering in the IE console is as follows: SCRIPT7002: XMLHttpRequest: Network Error 0x80070057, Invalid arg ...

Tips for resolving the final item issue in Owl Carousel when using right-to-left (RTL)

Encountering a bug with the rtl setting in owl-carousel. When the rtl is applied to the slider and I reach the last item, the entire slider disappears! Here's the code snippet: var viewportWidth = $("body").innerWidth(); if (viewportWidth & ...

Animate the height transition of contenteditable after a line of text is added (using shift+enter) or removed

Currently, the contenteditable attribute is being utilized on the <div> tag to enable autogrow functionality similar to a textbox. Additionally, there is an attempt to incorporate a height transition. While most aspects are functioning correctly, the ...

Communication between parent and child elements in jQuery

I am developing a plugin that focuses on the manipulation of checkboxes. However, I am currently facing an issue. After retrieving JSON data, I need to establish connections between children and parents. Each child contains a "data-parent" attribute with a ...

There seems to be a column in the MySQL INSERT query that is unidentifiable and does not exist in the list of fields

id and cost are required as integers and cannot be left empty. I encountered the following error message: 'Error: ER_BAD_FIELD_ERROR: Unknown column 'undefined' in 'field list'' var sql = "INSERT INTO Paintings(` ...

Planes in Three.js that are overflowing may have their opacity adjusted

My current challenge involves aligning two planes in the same (or closest possible) position. When two planes made of different materials and colors occupy the same space, depending on the camera angle and view perspective, the front plane's opacity ...

MongoDB suggests

I'm currently developing an app that requires autocomplete functionality for search. I've started implementing it using regular expressions (regexp), but I'm unsure if this is the optimal approach. Each new character input in the search bar ...

`Could not locate JavaScript files within the _nuxt directory`

I encountered a strange issue with my Nuxt 2.15.4 project. While the code was functioning perfectly locally (<--dev & build-->), it fails to load correctly on the server after the build process. The error message I am seeing is: GET https://example.c ...

The YYYY-dd-mm input mask pattern is malfunctioning

Hello, I am having trouble creating a pattern for an input field in the format YYYY-mm-dd. My code is not working properly. Can someone please help me correct my code? Any assistance would be greatly appreciated. <html> <head> <title>En ...