首页 > 其他 > 详细

组件之间使用Prop传递数据

时间:2017-02-07 15:59:28      阅读:254      评论:0      收藏:0      [点我收藏+]
<div id="example">
    <father></father>
</div>

<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script type="text/javascript">

    Vue.component(child, {
        props: [myMessage],
        template: <div>{{myMessage}}<input v-model="counterMessage"></div>,
        computed: {
            counterMessage: function () {
                return this.myMessage.trim().toLowerCase()
            }
        }
    })

    Vue.component(father, {
        template:             <div>                <div>{{parentMsg}}</div><br><child :my-message="parentMsg"></child>            </div>,
        data: function () {
            return {
                parentMsg:  a22 asdasdasd sdasdAS asdAS 
            }
        }
    });

    new Vue({
        el: #example
    })

</script>

 

组件之间使用Prop传递数据

原文:http://www.cnblogs.com/zhishaofei/p/6374402.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!