[vue] vue怎么实现强制刷新组件?
$forceUpdate?
我想到的是加一个new date()
强制重新渲染
this.$forceUpdate()
强制重新刷新某组件
//模版上绑定key
<SomeComponent :key="theKey"/>
//选项里绑定data
data(){
return{
theKey:0
}
}
//刷新key达到刷新组件的目的
theKey++;
v-if
?
this.$forceUpdate()
v-if
this.$nextTick(()=>{})
组价上加 key 然后改变key值
调用this.$forceUpdate()强制重新渲染组件
利用v-if指令的特性
Most helpful comment