vue父子传值更新不及时

父级:

<!-- http采集器 -->
  <NodeHttp ref="http" :datanode="nodeData"></NodeHttp>

import NodeHttp from '../node/NodeHttp.vue'

  components: {
    NodeHttp,
  },

//点击传值
nodeClick(){
    this.nodeData = '222';
}

子级:

<script>
   export default {
        name: 'http',
        props: {
            datanode: Object,
            // cancel: Function
        },
        data() {
            return {
                visible: false,
                setting: this.datanode,
            }
        },
        watch: {
            datanode(val) {
                this.setting = val;  需要监听
            }
        },
        created() {

        },
        methods: {
            show() {
                this.visible = true;
            

            },
            hide() {
                this.visible = false
            },
        }
    }
</script>

  

posted @ 2022-02-28 17:32  前端—小白  阅读(105)  评论(0编辑  收藏  举报