vue

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

2019-10-11  本文已影响0人  凌晨丶杨先森灬

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

① 子组件上 添加 v-if

② 父组件 监听数据

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

具体实现

子组件

<template>
      <a-input>
        <a-icon @mousedown="cleanClick"/>
        <span slot="suffix" v-show="!cleanInputType"> 分</span>
      </a-input>
 </template>
cleanClick() {
  
  // 判断如果是关联小题 那么就开始让他的题型状态为false

  if (this.scoreParam.structureType) {

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

父组件

<to-score-templeate
  v-if="reFresh"
  @my-reFresh="myReFresh"
 ></to-score-templeate>
myReFresh(msg){
  this.reFresh= false
  this.$nextTick(()=>{
    this.reFresh = true
  })
  console.log('接收的数据--------->'+msg)//接收的数据--------->我是子组件中的数据
}
上一篇下一篇

猜你喜欢

热点阅读