Vue 全局组件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<title>Document</title>
</head>
<body>
<div id="app">
<button-demo></button-demo>
</div>
<script>
Vue.component('button-demo',{
data () {
return {
count:0,
}
},
template:`<div>
<button v-on:click='count++'>点击了{{ count }}次</button>
<ButtonDemo></ButtonDemo>
</div>`,
})
Vue.component('ButtonDemo',{
data () {
return {
count:0,
}
},
template:`<div>
<button v-on:click='count++'>驼峰方式的点击了{{ count }}次</button>
</div>`,
})
var vm=new Vue({
el:"#app",
data:{
}
})
</script>
</body>
</html>