[Vuejs]-Html within Javascript

1👍

Try using v-html directive instead of v-text on your HTML.

<div class="line" v-if="lyrics.show" v-html="lyrics.currentLine"></div>

-1👍

There are two main ways to create elements in Javascript. The first is to use createElement() function:

const div = document.createElement("div");
div.innerHTML = "I'm a div";
div.id = "myDiv";
document.body.appendChild(div);
#myDiv{
   color: red;
}

The second is to use the innerHTML property on an existing element:

const div = document.getElementById("myDiv");
div.innerHTML = "<p>I'm a p tag</p>";
p{
   color: green;
}
<div id="myDiv"></div>

Leave a comment