子组件调用父组件方法带参数

子组件调用父组件方法带参数

  • 父组件
### template
<DBTableSelect ref="DBTableEdit" @customEvent="handleCustomEvent" @close="closedDrawDBTable"
                 v-if="showDrawDBTable"/>
### js                   
import DBTableSelect from "./DBTableSelect.vue";
  name: "tableRelation",
  components: {DBTableSelect},
    
    
  handleCustomEvent(data){
      console.log('接收到的信息: ',data)
  }
  • 子组件
let obj = {fieldsData: this.tableFieldArr,tableNames: this.tableList,databaseUnid: this.databaseUnid}
          this.$emit('customEvent', obj)
  • 参数可以为数组、对象、单个参数
posted @ 2023-08-03 17:51  ElloeStudy  阅读(36)  评论(0编辑  收藏  举报