I am working with Vue.js, and for some reason it just stopped working. I can't seem to find my mistake - been looking at it for hours.
This is my HTML file - just dependencies and a table that displays the data in users
.
<!DOCTYPE html>
<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<script
src="https://code.jquery.com/jquery-3.3.1.min.js"
type="text/javascript">
</script>
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
rel="stylesheet"
>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
type="text/javascript">
</script>
<script
src="https://cdn.jsdelivr.net/npm/vue"
type="text/javascript">
</script>
<script src="/js/app.js" type="text/javascript"></script>
<div class="container">
<div id="app">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Personal Number</th>
<th>Volcano Amount</th>
</tr>
</thead>
<tbody>
<tr v-for="user in users">
<td><% user.name %></td>
<td><% user.personal_number %></td>
<td><% user.volcano_amount %></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
And this is the app.js file - which just inits the Vue instance, creates the users
array, and runs an AJAX request that updates the users
array.
var app = new Vue({
el: '#app',
data: {
users: []
},
mounted: function() {
var vue_object = this;
$.getJSON('users', function(data) {
vue_object.users = data;
});
},
delimiters: ['<%', '%>']
});
The result is extremely disappointing - Everything is in plain HTML. The table has 2 rows - the header, and a row with <% user.xxx %>
, as if Vue did not exist.
I guess this means that something is not running, though the app.js itself does run (I tried adding console.log and it did print)
Hope you have good ideas :)