06-基础-组件-父子组件传值-总结

<!DOCTYPE html>
<html>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width,initial-scale=1.0'>
    <meta http-equiv='X-UA-Compatible' content='ie=edge'>
    <title>Document</title>
</head>

<body>
    <div id='app'>
        <!-- 2. 使用组件  赋值 -->
        <com-a :a="b"></com-a>
    </div>
    <script src='./vue.js'></script>
    <script>
        Vue.component("com-a", {
            template: `
          <div>
              我是来自父组件的数据--{{a}}
            </div>
        `,
            // 1. 定义一个属性(变量) 此时没值
            props: ["a"],
            methods: {}
        });
        new Vue({
            el: '#app',
            data: {
                b: "我是b"
            },
            methods: {
            }
        });
    </script>
</body>

</html>

posted @ 2019-05-28 22:51  193557749  阅读(173)  评论(0编辑  收藏  举报