I created a hook to reload my data from the database on a button click:
<template>
<base-projects :projects="projects" />
</template>
<script>
import { mapGetters } from 'vuex';
import Projects from './Projects';
import projectService from '@/services/projectService';
export default {
components: { Projects },
computed: {
...mapGetters([
'projects'
])
},
created() {
projectService.getAllCompanyProjects();
},
};
</script>
So that works fine, but only if I click the first time. If I click a second time, it doesn't reload the data a second time. Does anyone know how to fix that issue?
Thank you in advance!
I assume that your data are reloaded from your database using
projectService.getAllCompanyProjects();function. Since you want to reload you data on "click" I suggest you to bind the "click" event to one of your component method.The
reloadDatamethod will be triggered by a "click" on the DOM of yourbase-projectscomponent.