I have a page with 2 structures using router-view. Menu and Content . or on my Menu I have a page called " Stores " on this " Stores " page has a table, I give an Axios.Get on my API and it returns me a JSON that plays to the " Stores table."
Problem: If my API has a new data, I have to reload the view.
Solution I'd like : When I clicked there on the menu in the item " Stores ", I wanted the current view (in the case " Stores ") reloaded for Axios to get Get back and the Table to bring the current data.
@EDIT
Stores.vue
<template>
<table class="table table-bordered table-striped dataTable" id="dataTable" width="100%">
<tbody class="animated fadeIn">
<tr v-for="item in dataItem" v-bind:key="item.Id">
<td class="text-left">{{item.Name}}</td>
</tr>
</tbody>
</table>
</template>
<script>
import axios from 'axios'
export default {
data: () => ({
dataItem: [],
errors: []
}),
created() {
axios.get('http://localhost:8090/API/Lojas')
.then(response => {
this.dataItem = response.data.Data
}).then(() => {
$('#dataTable').DataTable( datatableConfigBR )
})
.catch(e => {
this.errors.push(e)
})
}
}
</script>
Menu.vue
<ul class="nav nav-second-level collapse">
<li>
<router-link :to="{ name: 'lojas' }">Lojas</router-link>
</li>
</ul>
routes.js
import lojas from './Lojas.vue'
const routes = [{
path: '/Content',
component: Content,
children: [
{
name: "lojas",
path: '/Lojas',
component: lojas
}
]
}
]
Thank you!