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

组件之间使用Prop传递数据

时间:2017-02-07 16:01:53      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:pre   log   model   div   logs   template   mod   his   input   

<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传递数据

标签:pre   log   model   div   logs   template   mod   his   input   

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

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