One example involves displaying array elements in an <ul>
, with each element starting with <li>
and ending with </li>
. Here is the attempted code:
clearedtaskslist: function(){
this.template='<ul>'
for(let i=0;i<this.archive.length;i++)
{
this.template+= '<li>' + this.archive[i].task '</li>'
}
this.template+='</ul>'
}
Is it possible to implement this functionality in vue?
Edit:
I need to display data from various events, but using v-for only results in the last event data being printed. For instance, I have to show completed tasks and the user who completed them every time someone triggers the related event.
clearedtaskslist: function(){
for(let i=0;i<this.archive.length;i++)
{
this.template += 'Task: ' + this.archive[i].task
this.template += ' user: ' + this.archive[i].taskuserID + '----||----'
}
}
This is how I retrieve the data and concatenate strings. However, I need to break the line after each cycle (and I am unsure how to do it).
<div style="margin: 0 auto; margin-top: 25px;" class="w-50">
<h5 v-if="archive.length>0"><i>Completed tasks</i></h5>
<div style="margin:0 auto;"> <p>{{template}}</p> </div>
</div>
This is where the data is displayed. The goal is to style the data effectively without relying on cumbersome string concatenation. Is there a way to achieve this in Vue?