新建vue1.html,将以下内容复制到该文件中,使用默认浏览器打开这个html文件即可
</head>
<body>
<div id="component-demo">
<button-counter></button-counter>
</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script type="text/javascript">
Vue.component('button-counter',{
data: function () {
return {
count: 0
}
},
template: '<button v-on:click="count++">You clicked me {{ count }} times.</button>'
});
new Vue({
el: '#component-demo'
})
</script>
</body>