vue 父子传值

1. .sync

2.ref

this.$refs.remindPage.setNotice(this.noticeCache);
this.$refs.子组件refName.子组件api();

 

3.props

//子组件定义
    props: {
      noticeCache: {
        type: Object,
        default: function() {
          return {}
        }
      }
    },

    console.log(this.noticeCache);
//父组件传值
<components-demo
   ref="remindPage"
   :noticeCache.sync="noticeCache"
   >
   </components-demo>

 

4.$emit

posted @ 2021-09-29 17:27  钱小柒  阅读(32)  评论(0编辑  收藏  举报