子組件中需要watch監聽被調用方案,對變動的值重新賦值即可,代碼如下:
父組件:
<CommentReply ref="child"></CommentReply>
this.$refs.child.getComment();
子組件:
watch: {
comments: function(newValue, oldValue) {
this.getComment();
}
},
注意:以上 comments 是子組件中被更新的值;getComment()是 父組件調用子組件的方法。