码迷,mamicode.com
首页 > 其他好文 > 详细

props 父向子组件传参

时间:2017-07-15 13:58:51      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:app   eth   ack   nts   back   data   turn   组件   com   

parent.vue 父

<template>
 <div class="wapper">
     <child message="hello!"></child>
</div>
</template>

 <script>
import child from ../components/child
 export default {
  name:wapper,
  components:{child}
 }
 </script>

child.vue 子

 <template>
    <div @click="up">点我</div>
</template>

<script>
  export default{
    data(){
      return {
        msg: 请输入值
      }
    },
    props:[message],
    methods: {
     up() {
       console.log(this.message)
    }
    }
  }
</script>

结果:

hello

props 父向子组件传参

标签:app   eth   ack   nts   back   data   turn   组件   com   

原文地址:http://www.cnblogs.com/queenw/p/7182306.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!