I am having a bit of an issue with rendering template. It seems that data from the main instance isn't transfered to the component.
This is the Vue code:
Vue.component('country-list', {
template: `
<tr class=parent>
<country v-for="country in countryList">
<td>Render This</td>
</country>
</tr>
`,
props: ['countries'],
data() {
return {
countryList: this.countries
}
}
});
Vue.component('country', {
template: `<tbody class=parent><slot></slot></tbody>`
});
let App = new Vue({
el: '#app-container',
data: {
countries: []
},
created() {
this.getCountries()
},
methods: {
getCountries() {
var self = this;
axios.get('/admin/countries')
.then(function (response) {
self.countries = response.data.data;
})
.catch(function (error) {
console.log(error);
});
},
filterCountries() {
},
updateCountry(event) {
}
}
})
And the HTML code which is using country-list template:
<table class="table table-striped table-hover">
<thead>
<tr>
<td>
<input
type="text"
id="country-filter"
@keyup="filterCountries">
</td>
</tr>
<tr>
<td>Country Name</td>
<td>Visible</td>
<td>Order</td>
<td>Actions</td>
</tr>
</thead>
<tbody>
<country-list></country-list>
</tbody>
</table>
What am I doing wrong here?
tbodyas a direct child oftr. You can't do that.