Answer the question
In order to leave comments, you need to log in
How to populate an array using a for loop?
Good afternoon, I'm trying to output an array of consecutive numbers, which should fill with a loop for
. I know that it can be made easier with the help v-for
, but I need it exactly as I described earlier. I tried to do so, but it did not give any results.
My app.vue:
<template>
<div id="app">
<p>{{ mounthDays }}</p>
</div>
</template>
<script>
export default {
name: 'app',
data () {
return {
mounthDays: []
}
},
mounted() {
for (var i = 1; i <= 31; i++) {
return this.mounthDays.push(i)
}
}
}
</script>
Answer the question
In order to leave comments, you need to log in
Return in a for loop? Something new.
My advice to you is to at least read learn.javascript.ru. Don't try to work with frameworks without understanding js.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question