【vue】組件重置刷新

主要是利用v-if的重建銷燬特性來重置:

<div class="flexdiv" v-if="isRouterAlive">

          <my-component>...</my-component>

</div>

 然後在data裏:

isRouterAlive:true

 在需要重置的地方:

this.isRouterAlive = false

this.$nextTick(() => (this.isRouterAlive = true))

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章