參考:https://www.jianshu.com/p/ed88beeafbe8
https://blog.csdn.net/weixin_44116302/article/details/109171210
應用場景是父組件有一個抽屜子組件,接受父組件傳遞的一個參數,然后當這個參數發生變化的時候需要子組件捕獲到父組件傳遞的參數,然后調用子組件內部的一個方法,
因此參考了上述兩篇文章,使用子組件中的watch監聽props參數中需要監聽的參數的那個字段,然后調用方法,為子組件填充參數。
具體代碼(子組件):
watch:{ //監聽參數中的drawerInfo.selectDate變化 'drawerInfo.selectDate':{ handler(newValue){ //console.log(newValue); this.GenerateTimeSpan(); }, immediate:true,//初次監聽即執行 }