父组件触发子组件的事件

2019-11-08  本文已影响0人  兰夏天

子组件上ref 写好值。
父组件上写一个触发事件,这个事件触发子组件的事件
例如
父组件

<div @click='handleclick'>
 <ordernum ref="myordernum"></ordernum>
</div>

<script>
methods:{
   // 订单弹层的确定按钮
    handleclick () {    
      this.$refs.myordernum.setkeynull('父调子组件的方法并给子组件传参')

}



</script>

子组件ordernum

<template>
  <div>
    <!-- 查询 -->
    <comsearch :queryCondition="queryCondition" @oksearch="oksearch"></comsearch>
    <a-table
      :columns="columns"
      :dataSource="datasource"
      :rowSelection="rowSelection"
      size="small"
      ref="table"
      :scroll="{ x:4000 }"
      :pagination="pagination"
      @change="handleTableChange"
    >
    </a-table>
  </div>
</template>
<script>
export default {
data(){
return{
selectedRowKeys :[1,1,24,4]
}
},
 methods: {
  setkeynull (e) {
    //  console.log(e)
      this.selectedRowKeys = []
    },
}
}
</script>
上一篇 下一篇

猜你喜欢

热点阅读