1.刷新整個頁面
- 使用v-if
3.使用this.$forceUpdate()方法
4.使用key-changing優(yōu)化組件
1===>
- this.$router.replace
- window.reload()
- router.go(0)
2===>
不做解釋
3===>
vue 組件強制刷新
場景:echarts組件不能及時刷新,組件內容不顯示,代碼改變后顯示。
this.$forceUpdate()
4===>
給需要刷新的內容綁定一個key
場景:數(shù)據(jù)更新后表格錯位,重新加載后才恢復原樣。
<el-table
:data="list"
:span-method="objectSpanMethod"
border
height="380"
style="width: 100%;"
:key="key"
>
.......................
</el-table>
props: {
thead: {
type: Array,
default: () => []
},
},
watch:{
thead(){
this.key += 1
}
},
data() {
return {
key:0
}
},