Answer the question
In order to leave comments, you need to log in
How to wrap a piece of dynamic content in a tag with SSR?
Task: wrap time (format - 28.09.2020 12:18) in span
I try like this
<template>
...
<p class="lf-news-item__date">{{ addTimeSpan(item.date) }}</p>
...
</template>
...
methods: {
addTimeSpan(date) {
if (process.client) {
let dateArr = date.split(' ');
let span = document.createElement('span');
span.innerHTML = dateArr[1];
return `${ dateArr[0] } ${ span }`
} else {
return date;
}
}
},
...
Answer the question
In order to leave comments, you need to log in
<template>
...
<p class="lf-news-item__date">
<span> {{ item.date.split(' ')[0] }} </span>
</p>
...
</template>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question