Vue.js学习笔记

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Vue.js学习模仿用</title>
  <script src="../Vue.js/vue.js"></script>
</head>
<body>
<div id="app">
    <input type="text" v-model="parentMsg">
    <my-component :my-message="parentMsg"></my-component>//注意my-message
    
</div>

</body>
<script>
//注册
Vue.component('my-component',{
    props:['my-message'],//注意my-message
    template:'<span>{{myMessage}}</span>'//注意myMwssage
})
//初始化根实例
new Vue({
    el:'#app',
    data:{
        parentMsg:'aa'
    }
    
})

</script>
</html>

三处地方却又两个不同的写法,如果在html里面用-连接字符的话是无法识别的 ,会报错,所以只能用驼峰记法,而在Vue.js里驼峰记法和-连接记法一样。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容