[英]How do I update the items async in a b-table from Bootstrap-Vue reusing the items provider function?
I am using Bootstrap-Vue v2.0.0-rc.11 and I just cannot get my head around how to update the table content.我正在使用 Bootstrap-Vue v2.0.0-rc.11,但我无法理解如何更新表格内容。 I am sure it is trivial.
我相信这是微不足道的。
I am pulling my content from a backend using an item provider function.我正在使用项目提供商 function 从后端提取我的内容。
<b-table
:items="myProvider"
>
The initial call works just fine with the following method.初始调用使用以下方法工作得很好。
export default {
methods: {
myProvider(ctx) {
let promise = axios.get('/backend?currentPage=' + ctx.currentPage);
return promise.then((response) => {
return(response.items || []);
});
},
To duplicate a row item I open a modal to enter a new name.为了复制一个行项目,我打开一个模式来输入一个新名称。 I make a backend call for the duplication which works well.
我对复制进行了后端调用,效果很好。 Now I want to refresh the content displayed in the table showing the new item.
现在我想刷新显示新项目的表中显示的内容。 How do I do this?
我该怎么做呢?
The easiest I can think of would be to call the item provider function (here: 'myProvider') again.我能想到的最简单的方法是再次调用项目提供者 function(此处为“myProvider”)。 I can do this from the modal but I cannot provide the correct parameter (here: 'ctx').
我可以从模式中执行此操作,但我无法提供正确的参数(此处:“ctx”)。
Is there an event to trigger/emit to reissue the backend call?是否有事件触发/发出以重新发出后端调用?
I tried things like:我试过这样的事情:
this.$refs.nameOfTable.$forceUpdate()
this.$refs.nameOfTable.$emit('XXX') // XXX = placeholder for various events
Any hint is appreciated.任何提示表示赞赏。 Thank you.
谢谢你。
refresh is not worked now刷新现在不起作用
you can use 'key' attribute instead.您可以改用“键”属性。
<b-table key="key" ... ></b-table>
data() {
return {
key: 1
}
this.key += 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.