Am having this issue of my component not displaying data even when I do `@{{ $data | json }}. Below is the code am working with
app.js
import Vue from 'vue';
import VueResource from 'vue-resource';
import Project from './components/Project.vue';
Vue.use(VueResource);
new Vue({
el: '#app',
components: { Project },
});
project.vue
<template>
<div class="columns is-multiline">
<slot></slot>
</div>
</template>
<script>
export default {
data() {
return {
projects: []
}
},
ready() {
this.fetchProjects();
//alert('ready');
},
methods: {
fetchProjects() {
this.$http.get('api/projects').then(function(projects) {
this.$set('projects', projects.data);
});
}
}
}
</script>
my view
<project>
<div class="column is-one-third" v-for="project in projects">
<div class="card is-fullwidth">
<a href="projects/@{{ project.slug }}">
<div class="card-content has-text-centered">
<div class="content">
<h3 class="title">
@{{ project.title }}
</h3>
<small>@{{ project.slug }}</small>
@{{ project.description }}
</div>
</div>
</a>
</div>
</div>
</project>
This was working fine before I decided to make it a component.
EDIT
I think the issue is from the <slot></slot>
part, cause if I include everything in the component template like this:
<template>
<div class="columns is-multiline">
<div class="column is-one-third" v-for="project in projects">
<div class="card is-fullwidth">
<a href="projects/{{ project.slug }}">
<div class="card-content has-text-centered">
<div class="content">
<h3 class="title">
{{ project.title }}
</h3>
<small>{{ project.slug }}</small>
{{ project.description }}
</div>
</div>
</a>
</div>
</div>
</div>
</template>
it working with the above, but not with this:
<template>
<div class="columns is-multiline">
<slot></slot>
</div>
</template>
Is it that am using the <slot></slot>
wrongly?