再次碰到监听子组件收到父组件传过来的值,如果这个值变革,页面中的值发现是不会跟着同步变革的。所以监听props中的值,不停监听。

代码:
- props: {
- start:{
- type: String,
- },
- end:{
- type: String,
- }
- },
复制代码
- computed:{
- myStart:function(){
- return this.start
- },
- myEnd:function(){
- return this.end
- }
- },
- watch: {
- myStart:function(newVal){
- if(newVal){
- this.startTime=newVal
- }
- },
- myEnd:function(newVal){
- if(newVal){
- this.endTime=newVal
- }
- },
- },
复制代码
来源:https://blog.csdn.net/qq_46617584/article/details/129725226
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作! |