Level 54
The "right" way to do this would be to use events. Basically, your add bet function would emit the new value, the sidebar, listening for that event would update the value accordingly.
1 like
please help, How to refresh the data of child component after i post some data on main component?
sidebar.vue
<template>
<h3 class="media-heading f-w-300 text-center m-t-0 m-b-0 text-muted">
₱ {{ userPoints.amount }}
</h3>
</template>
<script>
export default {
props: ['user'],
data() {
return {
userPoints: [],
}
},
mounted() {
this.getUserPoints();
},
methods: {
getUserPoints() {
this.$http.get('/api/user/' + this.user.id)
.then(response => {
this.userPoints = response.data;
});
},
}
}
</script>
then my main component has
import sidebar from '../../components/sidebar.vue';
export default {
// i use mixins? is this correct?
mixins: [sidebar],
// then may method
methods: {
AddBet: function (value) {
// post
//then i want to refresh may sidebar with user points
}
}
}
The "right" way to do this would be to use events. Basically, your add bet function would emit the new value, the sidebar, listening for that event would update the value accordingly.
Please or to participate in this conversation.