简体   繁体   English

在 vue JS 中重新加载组件

[英]Reload component in vue JS

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.我刚刚开始使用 VueJs 我点击它时有一个刷新按钮 我希望它重新加载/刷新我拥有的组件和表,我尝试了 forceUpdate 方法以及密钥更改方法,但它没有似乎工作。 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 refreshList 是调用的方法,但到目前为止它是空的,因为还没有任何效果

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>

You should update the data passed to the statusBar component.您应该更新传递给statusBar组件的数据。 Since props are reactive, it will re-render.由于道具是反应性的,它会重新渲染。

refreshList() {
 ....logic to update `stats`....
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM