samedi 30 mars 2019

Vue: How to refresh new data?

I am using Vue Components in my blade file. Whenever I need to 'refresh' my customer object, I emit an event to the parent (shown below) and customer is refreshed and any props it passed to children will be shown with their updated values.
This is all well and good so far but I am now using some PHP values. I am passing a prop automatic-payments-enabled and it's using a php value. How can I have that value refresh after making an API call that changes it?

Blade file

<div id="app">

   <Account 
     :customer="customer"
     :automatic-payments-enabled={!! json_encode($customer->automaticPaymentsEnabled()) !!}
   >
</div>

app.js

Vue.component('Account', 
    require('./components/Account.vue').default);

new Vue({
    el: "#app",
    data() {
        return {
            customer: null
                       }
                }
        mounted() {
            this.getCustomer();
        }
        methods: {
            getCustomer: function() {
                 //api call to server
                 this.customer = response.data
            } 
        }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire