vue 父组件 监听子组件 事件 (强制刷新子组件的)

子组件改变父组件传递的 参数 不刷新

① 子组件上 添加 v-if

② 父组件 监听数据

this.reFresh= false  
 this.$nextTick(()=>{
 this.reFresh = true 
   })

具体实现

子组件


cleanClick() {
  
  // 判断如果是关联小题 那么就开始让他的题型状态为false

  if (this.scoreParam.structureType) {

    this.scoreParam.multipleFlag = false;
    this.scoreParam.fillBlankFlag = false;
  }
  this.$emit('my-reFresh', this.scoreParam);
},

父组件


myReFresh(msg){
  this.reFresh= false
  this.$nextTick(()=>{
    this.reFresh = true
  })
  console.log('接收的数据--------->'+msg)//接收的数据--------->我是子组件中的数据
}

你可能感兴趣的:(vue 父组件 监听子组件 事件 (强制刷新子组件的))