props里的值在mounted里拿不到的问题
有时候父组件通过props把值传给子组件,
子组件在mounted里用props传过来值作为参数去发送请求,有时会拿不到值的情况
利用监听可以解决这个问题
原:
父组件
<CalendarView :staffId="staffId"/>
子组件
props: ['staffId'],
 mounted() {
        this.getScheduleInfo(staffId)
}
现:
 watch:{
        staffId: function (val){
                 this.getScheduleInfo(val)
        }
}
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号