element表格變化后自動刷新的兩種方案
方案一:
在table上加上:key="Math.random()",但是這種方法需要觸發(fā)熱更新才會刷新數(shù)據(jù),比如保存
<el-table :key="Math.random()" :data="goodsList" style="width: 100%">
<el-table-column label="ID" width="180">
<template #default="scope">
<div style="display: flex; align-items: center">
<span style="margin-left: 10px">{{ scope.row.id }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="商品名" width="180">
<template #default="scope">
<el-popover effect="light" trigger="hover" placement="top" width="auto">
<template #default>
<div>name: {{ scope.row.name }}</div>
</template>
<template #reference>
<el-tag>{{ scope.row.name }}</el-tag>
</template>
</el-popover>
</template>
</el-table-column>
<el-table-column label="圖片" width="180">
<template #default="scope">
<div style="display: flex; align-items: center">
<span style="margin-left: 10px">...</span>
</div>
</template>
</el-table-column>
<el-table-column label="價格" width="180">
<template #default="scope">
<div style="display: flex; align-items: center">
<span style="margin-left: 10px">{{ scope.row.price }}</span>
</div>
</template>
</el-table-column>
<el-table-column label="操作">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">
Edit
</el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">
Delete
</el-button>
</template>
</el-table-column>
</el-table>方案二:
定義成響應式數(shù)據(jù)
如果定義成 const goodsList = [ ] 是不會自動刷新的
定義成 const goodsList = ref([ ]) 就行
到此這篇關于element表格變化后自動刷新的兩種方案的文章就介紹到這了,更多相關element表格自動刷新內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Vue中登錄驗證成功后保存token,并每次請求攜帶并驗證token操作
這篇文章主要介紹了Vue中登錄驗證成功后保存token,并每次請求攜帶并驗證token操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09
淺談webpack SplitChunksPlugin實用指南
這篇文章主要介紹了淺談webpack SplitChunksPlugin實用指南,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-09-09
vue組件中使用props傳遞數(shù)據(jù)的實例詳解
這篇文章主要介紹了vue組件中使用props傳遞數(shù)據(jù)的實例詳解,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2018-04-04
Vue render函數(shù)實戰(zhàn)之實現(xiàn)tabs選項卡組件
這篇文章主要介紹了Vue render函數(shù)實戰(zhàn)之實現(xiàn)tabs選項卡組件的相關知識,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2019-04-04
Vue3+X6流程圖實現(xiàn)數(shù)據(jù)雙向綁定詳解
這篇文章主要為大家詳細介紹了Vue3如何結合X6流程圖實現(xiàn)數(shù)據(jù)雙向綁定,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下2024-03-03

