I'm making a table that contains randomly created numbers, but when I called contacts() in v-for, for some reason, I'm getting this red warning:
vue.esm.js?efeb:591 [Vue warn]: You may have an infinite update loop in a component render function.found in---> at src\App.vue
with bunch of empty arrays like "[]..."
Why is this is and how to fix it?
<template>
<div id="app">
<table border=1 width =50% id="list">
<tr v-for="i in [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]">
<td v-for="contact in contacts()">{{contact}}</td>
</tr>
</table>
</div>
</template>
<script>
import Vue from 'vue'
export default {
name: "App",
data: function() {
return {
result: [],
row: Math.floor(Math.random() * 16) + 1
}
},
created() {
let start = Math.floor(Math.random() * 16) + 1
for (var i = 0; i < 16; i++) {
this.result[i] = start++
if (start > 16) start = 1
}
},
methods: {
contacts: function() {
let snapshot = this.result.splice(0, this.row)
console.log(snapshot)
return snapshot
}
}
}
</script>