Fork me on GitHub

vue中强制组件重新渲染

1.第一种
<template> <my-chilid v-if="show"/> </template> <script> export default{ data(){ return { show:true, list:[] } }, watch:{ list(){ this.show= false this.$nextTick(()=>{ this.show= true }) } } } </script>

2.第二种

<template>
   <my-chilid :key="mykey"/>
</template>
 
<script>
   export default{
       data(){
          return {
                mykey:1,
                list:[]
            }
       },
       watch:{
             list(){
                 ++this.mykey
            }
       }
}
</script>

 

posted @ 2020-09-25 11:38  欢欢11  阅读(255)  评论(0编辑  收藏  举报