I work with Vue.js and Django. My goal is to display a list of the boxes I receive through the REST API.
Here is my JavaScript code:
Vue.component('bin-detail', {
template: '#bin-detail',
props: ['bin']
});
var app = new Vue({
el: '#table',
data: {
message: "Hallo",
bins: []
},
mounted: function() {
$.get('/api/bins/', function (data) {
app.bins = data.results;
})
},
delimiters: ['<%', '%>']
});
And my HTML:
<div id="table">
<h1><% message %></h1>
<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr v-for="bin in bins" is="bin-detail" :bin="bin"></tr>
</tbody>
</table>
</div>
<template id="bin-detail">
<tr>
<td>
<% bin.name %>
</td>
</tr>
</template>
These messages are displayed correctly, but after receiving the GET request, the name remains on the page "% lt.% Bin.name%>. Using Vue-Inspector, I see that the component was generated correctly But the template does not update:
Any idea what I do wrogn ?
source
share