I am trying to convert this JavaScript code to Vue JS ES5. This is my Javascript that displays the table:
window.addEventListener("load", function(){
// simple array
var data = ["cat", "mouse", "bird", "goat", "monkey", "giraffe","cow","donkey","mice", "camel", "elephant", "bufalo", "jade","zebra","goose","hen","zat"];
// html table
var perrow = 4, // 7 items per row
html = "<table><tr>";
// Loop through array and add table cells
for (var i=0; i<data.length; i++) {
html += "<td>" + data[i] + "</td>";
// Break into next row
var next = i+1;
if (next%perrow==0 && next!=data.length) {
html += "</tr><tr>";
}
}
html += "</tr></table>";
document.getElementById("container").innerHTML = html;
});
how can I convert to vue js. my vue code is
<script type="text/javascript">
var appVM= new Vue({
el:'#app',
mydata:{["cat", "mouse", "bird", "goat", "monkey", "giraffe","cow","donkey","mice", "camel", "elephant", "bufalo", "jade","zebra","goose","hen","zat"];
},
</script>
<table id="myTable" class="display table" width="100%">
<tbody>
<tr v-for="data in mydata">
<td> data to appear in this section</td>
</tr>
</tbody>
</table>