<div id="app">
<h3-component></h3-component>
</div>
<script type="text/javascript">
var vm = new Vue({
el : "#app",
data :{},
components:{
H3Component : {/*直接在 DOM (即非字符串的模板) 中使用时只有 kebab-case 是有效的,推荐使用kekab-case方式命名*/
template:"<h3>h3 components</h3>"
}
}
});
</script>
vue要求如果创建组件时使用驼峰命名,调用组件的时候需要将驼峰改为横线-写法,因为html对大小写不敏感。
然而我全部使用横线写法也报错,所以就使用驼峰命名,html调用时使用横线写法吧。
另外,全局注册组件时,组件定义在前,Vue对象定义在后。