子组件通过$emit触发父组件的事件时,参数的传递

子组件.vue

<template>
  <div>
    <el-table :data="comSchemaData" highlight-current-row height="517" @row-click="quoteProps">
      <el-table-column label="schema名称" prop="name">
      </el-table-column>
    </el-table>
  </div>
</template>

子组件.ts

quoteProps(row) {
    this.$emit(‘toProps‘,row)
  }

父组件.vue

<com-schemas @toProps="toProps"></com-schemas>

注意:html中的toProps不带子组件传进来的参数,否则会报错,在ts中toProps的形参直接使用子组件传入参数即可

父组件.ts


import comProps from ‘./comProps.vue‘;


@Component({

  components: {

    ‘com-props‘: comProps

  },

)

export default class ExpandTable extends Vue {

toProps(row){
    console.log(row);
  }}
时间: 2024-08-25 11:16:57

子组件通过$emit触发父组件的事件时,参数的传递的相关文章

vue--父组件向子组件传参--父组件定义v-bind:参数名--子组件接收props----子组件调用父组件的方法(子组件向父组件传参)父组件@事件名称--子组件接收this.$emit

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" con

Vue事件在组件中的简单使用以及子组件事件触发父组件自定义事件

在Vue中,通过v-on 来监听DOM事件,可以通过@简写代替. 一个简单的在组件中的事件调用示例 在template的Html中使用v-on或@监听一个click事件,并指定事件执行handleClick方法. handleClick需要在组件的methods集合中定义. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta

vue 简单实现父组件向子组件传值,简单来说就是子组件肆意妄为的调用父组件里后台返回的值

首先在于父子组件传值的方法很多,本人在这里只是简单描述一下一个组件里面引用了子组件,那么子组件如何才能获取父组件中后台返回的值呢? 首先调用组件相信大家都应该明白了(不明白的自己撸撸文档), <info-head :orderInfo="orderInfo" :changePrice="changePrice"></info-head> 上面的是父组件中引用的子组件,其中orderInfo为父组件中定义的接收后台返回的值需要向平常一样的去定义

React-组件嵌套-子组件通过委托向父组件传值

一.简述 父组件嵌套子组件,父组件的处理函数通过属性的方式赋值组子组件( <GenderSelect handleSelect={this.handleSelect}></GenderSelect> ),子组件通过触发事件,委托调用父组件的处理函数,从而实现把值传给父组件(return <select onChange={this.props.handleSelect}>, handleSelect: function(event) { this.setState({g

vue组件之间传值、父组件获取子组件的方法

1.子组件向父组件传值 子组件 <template>     <div class="app">        <input @click="sendMsg" type="button" value="给父组件传递值">     </div> </template> <script> export default {       data () {    

vue中父子组件主动获取值 父组件向子件间的传值

父组件主动获取子组件的数据和方法: 1.调用子组件的时候定义一个ref <v-header ref='header'></header> 2.在父组件里面通过 this.$refs.header.属性 this.$refs.header.方法 子组件主动获取父组件的数据和方法 this.$parent.数据 this.$parent.方法 父组件向子件间的传值 1.父组件调用子组件的时候 绑定动态属性 2.在子组件里通过props接受父组件传过来的数据 原文地址:https://w

vue2.0中子组件通过v-modal改变父组件中的值

父组件代码: <template lang="pug"> div p this is father child(v-model="data") </template> <script> import child from "./childrenS.vue"; export default{ data(){ return { data: [1, 2, 3] } }, components: { child },

vue 和react中子组件分别如何向父组件传值

vue子组件和父组件双向传值: 子: Vue.component("childComponent",{ template:`<div><p @click='postData'>向父组件传值:点击我</p>{{result?'开':'关'}}</div>`, props:["result"], data(){ return{ message:'从子组件传过来的数据' } }, methods:{ postData(){

jquery-iframe内触发父窗口自定义事件-

例如父窗口定义了一个事件. top: $(dom1).bind('topEvent', function(){}); 那么iframe里面的元素怎样触发父窗口dom1的事件呢?这样吗? $(dom1, parent.document).trigger('topEvent'); 看似正确,实则误导人. *因为父窗口的jquery对象与iframe里面的jquery对象实际为两个对象(function),iframe里面的jquery并不会触发另一个jquery对象定义的事件.除非你在iframe这