我是靠谱客的博主 淡定玫瑰,这篇文章主要介绍09-组件通信-父传子(props的驼峰标识),现在分享给大家,希望可以做个参考。

09-组件通信-父传子(props的驼峰标识)

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>组件通信-父传子(props的驼峰标识)</title>
</head>

<body>
    <div id="app">
        <!-- 当props中用驼峰命名法时如cInfo,绑定时要改为v-info -->
        <cpn :c-info="info"></cpn>
    </div>

    <template id="cpn">
        <div>
            <h2>{{cInfo}}</h2>
            <h2>{{childMessageAge}}</h2>
        </div>

    </template>


    <script src="../js/vue.js"></script>

    <script>
        // root组件
        const cpn = {
            template: "#cpn",
            props: {
                cInfo: {
                    type: Object,
                    default() {
                        return {}
                    }
                },
                childMessageAge: {
                    type: String,
                    default: 'aaa'
                }
            }
        }



        const app = new Vue({
            el: "#app",
            data: {
                info: {
                    name: "coderwhy",
                    age: 19,
                    height: 1.99
                }

            },
            components: {
                cpn
            }
        })
    </script>
</body>

</html>

最后

以上就是淡定玫瑰最近收集整理的关于09-组件通信-父传子(props的驼峰标识)的全部内容,更多相关09-组件通信-父传子(props内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(46)

评论列表共有 0 条评论

立即
投稿
返回
顶部