Vue:如何刷新新数据?

时间:2019-03-30 17:21:31

标签: laravel vue.js laravel-5

我在刀片文件中使用Vue组件。每当我需要“刷新”我的客户对象时,我都会向父级发出一个事件(如下所示),客户将得到刷新,并且传递给子级的任何道具都将显示其更新后的值。
到目前为止,一切都很好,但是我现在使用一些PHP值。我正在传递道具automatic-payments-enabled,它正在使用php值。进行更改后的API调用后,如何刷新该值?

刀片文件

<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
            } 
        }
}

1 个答案:

答案 0 :(得分:0)

我认为$ customer实际上是一个Model。如果是这样,您可以使用

$customer->fresh()->automaticPaymentsEnabled()
相关问题