VueJS计算的属性不会更新

时间:2020-03-07 11:37:27

标签: vue.js

我有一个计算所得的属性:

outputData() {
        if(this.yearSelected) {
            let res = this.taikoData
                        .map(item => {
                            return {
                                showName: item.showName,
                                IdMitgliedschaftenPersonen: item.IdMitgliedschaftenPersonen,
                                PaidProp: item.paidDate
                                                    .filter(item => item.paidDate.substr(0,4)==this.yearSelected)
                                                    .sort((a,b) => (a.paidDate>b.paidDate) ? 1 :( (b.paidDate>a.paidDate) ? -1 : 0 )),
                             }   
                        })
        return res
        } 
        else {
            return []
        }
}

它从taikoData对象(在安装过程中填充)接收数据,并对其进行过滤以匹配当前年份。然后,我可以添加一个会员缺席的月份,而不必支付每月的订阅费。

screenshot of user interface

屏幕截图显示了用户界面。单击按钮时,我添加了月份,并通过事件更新了taikoData对象。数据也被保存在数据库中。我想立即在数据表中看到更新的数据。但是,它不会更新。仅当来回更改yearSelected-filter时才显示更新的数据(或者当然是在刷新页面时显示)。

到目前为止,我已经尝试过:

1)收到$ emit-data时,在method-prop函数内的this。$ forceUpdate()。没用

2)使用初始等于0的反变量扩展条件:if(this.yearSelected || counter> 0)。每次将数据发送回父级时,计数器都会增加。

数据表是vuetify数据表:

<v-data-table
                    :items="outputData"
                    :headers="headers"
                    :search="search"
                    sort-by="showName"
                     :footer-props="{
                        'items-per-page-options': [20,50,75,-1],
                     }"
                >

最初在这里检索taikoData:

async mounted()
    {
        let res = await api.get("https://requestURL")
        res = res.data.records
        this.taikoData = res
}

0 个答案:

没有答案
相关问题