美文网首页
(17.06.21)Vue组件、组件的定义和使用、组件之间的数据

(17.06.21)Vue组件、组件的定义和使用、组件之间的数据

作者: 张不困_ | 来源:发表于2017-11-24 17:34 被阅读0次

Vue组件
组件        Component


    定义组件
        公共的组件

        Vue.component('组件的名字',{
            template:'模板',
            data(){
                return {
                    数据
                };
            }
        });

        私有的组件
        new Vue({
            components:{
                '组件的名字':{
                    template:'模板',
                }
            }
        });

    使用组件
        <组件的名字></组件的名字>

template一定要有一个根元素
组件写在template中可读性差
    <template id=""></template>

    <script type="x-template" id=""></script>


组件之间数据通信
    父级给子级数据

    <test :aaa="xxx"></test>
    Vue.component('test',{
        template:'',
        props:['aaa']
        或者
        props:{
            aaa:String
        }
    });

子级给父级数据


Vuex
    http://vuex.vuejs.org/

Vue    filter     过滤器


路由     ***
    http://router.vuejs.org/


vue-cli    Vue-脚手架


官网文档
论坛
qq群

相关文章

网友评论

      本文标题:(17.06.21)Vue组件、组件的定义和使用、组件之间的数据

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