1 组件定义: 组件是可复用的 Vue 实例
```html
<div id="components-demo">
<!-- 组件可以复用 -->
<button-counter></button-counter>
<button-counter></button-counter>
<button-counter></button-counter>
</div>
<script>
// 定义一个名为 button-counter 的全局组件
Vue.component('button-counter', {
data: function () {
return {
count: 0
}
},
template: '<button v-on:click="count++">You clicked me {{ count }} times.</button>'
})
</script>
```
注意:
1:组件选项中没有 `el` 选项
2:组件的 `data` 选项必须是函数
3:组件中必须是单个根元素