组件之间使用Prop传递数据

Posted zhishaofei3

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了组件之间使用Prop传递数据相关的知识,希望对你有一定的参考价值。

<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传递数据的主要内容,如果未能解决你的问题,请参考以下文章