[Vuejs]-V-for – looping out basic numbers

0👍

Your code should work, please double check the value of pageCount. Here is a working example using latest Vue.js version:

new Vue({
  el: "#app",
  data: {
    pageCount: 10
  },
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>

<div id="app">
  <button v-for="(n, i) in pageCount">{{ n }}</button>
</div>

-2👍

Did you declare the pageCount in the on data key
//HTML

{{ n }}

//Javascript
<script type="text/javascript">
    var vm = new Vue({
        el: "#root", 
        data: {
            pageCount : [1,2,3,4,5,6]
        }


    })
</script>

-2👍

I’m not sure what you’re using v-for for if pageCount is an integer, if you just want the pageCount then you’d just do:

<button>{{ pageCount }}</button>

Leave a comment