Answer the question
In order to leave comments, you need to log in
How to use v-for as a mutable property loop?
hello i have
<div v-for="i of 10" :key="i" class="frame" >
</div>
backgroundImage =
`url(${require("../assets/images/slides/" + this.$assetsResolution + "/" + i + ".jpg")})`;
Answer the question
In order to leave comments, you need to log in
Component pseudocode:
<div v-for="index of 10" :key="index" class="frame" :style="`background-image: url(${getImageUrl(index)})`" >
{{ index }}
</div>
{
methods: {
getImageUrl(index) {
return `/images/slides/${this.$assetsResolution}/${index}.jpg`;
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question