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

上一篇:this.$refs[‘form‘].resetFields()方法重置表单无效的坑


下一篇:Cascader 级联选择器使用踩坑记