VUE JS中的重新加载组件
我刚开始使用vuejs 当我单击它时,我有一个刷新按钮,我希望它重新加载/刷新一个组件和一个桌子,我尝试了forceupdate方法以及关键更改方法,但似乎不起作用。 有人知道如何使它起作用吗? 谢谢你!
这是我的按钮:
<v-col cols="1" style="max-width: 40px;">
<v-icon @click="refreshList">mdi-refresh</v-icon>
</v-col>
刷新清单是一种方法,但它是空的,到现在为止,
这是我想重新加载的组件,
<v-row dense>
<v-col cols="12">
<statusBar :stat="stats" mode="site"/>
</v-col>
</v-row>
这是我想重新加载的桌子:
<v-col cols="8">
<v-data-table
:headers="headers"
:items="displayed"
:search="search"
:loading="loading"
style="background-color: #292B3D;"
@click:row="openDetail">
<template v-slot:[`item.status`]="{ item }">
<v-chip
v-if="naming[item.status].color == '#FFFFFF'"
class="ma-2"
text-color="black"
:color="naming[item.status].color">
{{ naming[item.status].lib }}
</v-chip>
<v-chip
v-else
class="ma-2"
:color="naming[item.status].color">
{{ naming[item.status].lib }}
</v-chip>
</template>
<template v-slot:[`item.connectors`]="{ item }">
<cardConnector :data="item.connectors"></cardConnector>
</template>
</v-data-table>
</v-col>
I'm just getting started with VueJs
I have a refresh button when I click on it I want it to reload/refresh a component and a table I have, I tried the forceUpdate method as well as the key changing method but it doesn't seem to work.
Does anyone knows how can I make it work?
Thank you!
Here's my button:
<v-col cols="1" style="max-width: 40px;">
<v-icon @click="refreshList">mdi-refresh</v-icon>
</v-col>
refreshList is the method called but it's empty till now since nothing has worked yet
Here's the component I want to reload:
<v-row dense>
<v-col cols="12">
<statusBar :stat="stats" mode="site"/>
</v-col>
</v-row>
And here's the table I want to reload:
<v-col cols="8">
<v-data-table
:headers="headers"
:items="displayed"
:search="search"
:loading="loading"
style="background-color: #292B3D;"
@click:row="openDetail">
<template v-slot:[`item.status`]="{ item }">
<v-chip
v-if="naming[item.status].color == '#FFFFFF'"
class="ma-2"
text-color="black"
:color="naming[item.status].color">
{{ naming[item.status].lib }}
</v-chip>
<v-chip
v-else
class="ma-2"
:color="naming[item.status].color">
{{ naming[item.status].lib }}
</v-chip>
</template>
<template v-slot:[`item.connectors`]="{ item }">
<cardConnector :data="item.connectors"></cardConnector>
</template>
</v-data-table>
</v-col>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该将传递的数据更新为
statusbar
组件。由于道具是反应性的,因此它将重新呈现。You should update the data passed to the
statusBar
component. Since props are reactive, it will re-render.