Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

vue组件props得不到父组件更新的数据

image.png
image.png
image.png
应该怎么在formContent中动态得到formValue的值?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

应该要在子组件中增加watch来监听父组件传过来的数值的变化。

watch: {
      // 父组件传值有变化,子组件需要进行监听才能让本身有变化
      formValue: function(curVal, oldVal) {
        // curVal是当前值,oldVal是旧值
        // 在这里进行数据变化后的相关处理
      }
    }

可以看一下父子组件传参的相关内容。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...