Between the traditional values parent component and subassembly

1. The parent component subassembly pass  

Subassembly

<li class="smaili" v-for="(item,index) in MonitorList" :key="index"> 
                            <input type="checkbox" id="jack" :value="item.monitoringPointName" v-model="checkedNames">
                            <label class="oneMenuChild" for="jack"  @click="sendMsg(item.monitoringPointAddress)">{{item.monitoringPointName}}</label>
                        </li>
  @ Click = "sendMsg (item.monitoringPointAddress) Click subcomponents time pass values ​​to the parent component
sendMsg(videoUrl){
      // this.$emit('getVideoUrl',videoUrl)
      this.$emit('getVideoUrl',videoUrl)
      
    }

Receiving parent component

< Div class = "jkmenuaaa"  > 
      < jkmenu @getVideoUrl = "videoUrlFn" /> // corresponding sub-component that automatically getVideoUrl
 </div>
videoUrlFn(data){
            console.log(data)
            this.monitorUrl = data
            this.videoPlay()
        },

2. The parent component sub-assemblies pass 

Parent component

: CurrScenicId = "currid" // To transfer data
 <div class="pop_con">
                <yjyd1 class="con" :currScenicId="currid" v-show="iconNowIndex===2"/>
                <yjyd2 class="con" v-show="iconNowIndex===0"/>
            </div>

Subassembly

export default{
  props: ['currScenicId']
}

  

 
 

Guess you like

Origin www.cnblogs.com/xhrr/p/11958574.html