【问题标题】:Refresh doesn't seems to work for my BootstrapVue <b-table> component刷新似乎不适用于我的 BootstrapVue <b-table> 组件
【发布时间】:2021-04-11 02:03:43
【问题描述】:

尽管我使用了刷新方法,但在我更改了它的 items[] 记录的某些元素后,我的 没有得到更新:

我必须添加一个虚拟/幽灵记录,然后将其删除以获取我想要更新的记录:

        this.items[this.posItemEdited] = element;
        //this.$refs['theTable'].refresh(); //Doesn't work
        //this.$root.$emit('bv::refresh::table', 'theTable'); //Doesn't work

        //TRICK: add and delete 
        this.items.push(element);
        this.items.splice(this.items.length - 1, 1);

【问题讨论】:

    标签: vue.js vuejs2 bootstrap-vue


    【解决方案1】:

    由于 Vue.js 反应性的警告,下面的代码不起作用

    this.items[this.posItemEdited] = element;
    

    Reactivity for arrays

    要解决这个问题你需要使用$set:

    this.$set(this.items, this.posItemEdited, element)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-13
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      • 2016-11-28
      相关资源
      最近更新 更多