I'm struggling a bit with setting up a conditional statement using v-if
along with a loop using v-for
in Vue. Here's what I have so far:
<div class="row form-group" v-for="(article, key, index) in articles" :key="key" v-if="article.pubdate(first four characters)">={{ filterYear}} >
I'm unsure of how to extract the first four characters from the pubdate
and treat it as a number, as well as how to pass in the filterYear
.
The data structure for articles
is JSON returned via Axios. However, the format of pubdate
is: year, space, then month (e.g., 2007 Aug or 2009 Aug 1).
My goal is to isolate a year and use it within the v-if
, displaying only articles written during or after that specific year. I also have similar functionality on the JavaScript side where values are identified and converted into a string (uid_string
). Check out this example on CodePen.