美文网首页
父子传参

父子传参

作者: 稻草人_9ac7 | 来源:发表于2019-12-04 16:25 被阅读0次
//父组件
<template>
         <div id="app">       
        <div>子组件传参:{{msg}}</div>  
            <Index msg="父组件传参" @gomsg="fn"></Index>
          <Navgation></Navgation>
    </div>
</template>
<script>
import Index from './children/index'
import Navgation from '@/components/Navigation'
export default {      
    data(){
        return{
         msg:""       
        }
    },
    methods: {       
        fn(res){
            this.msg=res
        }      
    },
    computed: {      
    },
    components:{
        Index,
        Navgation   
    }    
}
</script>
<style lang="less" scoped> 
</style>
//子组件
<template>
    <div>
        <div>子组件:{{msg}}</div>     
    </div>
</template>
<script>
export default {   
props:['msg'],    
    methods: {  },
    created() {
        //子传父
        this.$emit('gomsg','李大爷') 
    },
}
</script>

相关文章

  • router-view 父子传参

    导语: 习惯了父子组件传参,今天聊一聊router-view传参。其实本质也是父子组件传参,方法一模一样,之前也提...

  • 父子传参

    在react中父子组件传参一 、父传子 子组件把值传给父组件在父组件中 其实可以把子组件里的方法用箭头函数,这样就...

  • 父子传参

  • 父子传参

    父组件 父组件向子组件传递数据 1.父组件绑定属性,给子组件传递数据2.子组件通过props接收父组件传递过来的数...

  • Flutter 父子组件传参 之 父组件向StatefulWid

    Flutter 父子组件传参 之 父组件向StatefulWidget有状态子组件传参https://www.we...

  • 父子传参(组件)

    第一种,父子组件通信 一.父组件向子组件传值 创建子组件,在src/components/文件夹下新建一个Chil...

  • vue 父子组件传参

    引用组件时,首先import引入,再注册,最后方可使用。同时注意,如果是驼峰式helloWorld ,在调用时就要...

  • react父子组件传参

    父子组件通信主要用到props,如下: 在父组件中: 在子组件中: 通过上面例子可以看出,在父组件中,我们引入子组...

  • vue 父子组件传参

  • vue父子组件传参

    1、父组件可以使用 props 把数据传给子组件。2、子组件可以使用 $emit 触发父组件的自定义事件。 vm....

网友评论

      本文标题:父子传参

      本文链接:https://www.haomeiwen.com/subject/trhlgctx.html