<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div id="app">
<span-d></span-d>
<span-d></span-d>
<span-d></span-d>
<span-d></span-d>
<span-d></span-d>
<span-d></span-d>
</div>
<script src="./vue.js"></script>
<script>
// 封装->组件
// Vue.filter();
// Vue.directive();
// newVue
Vue.component('span-d', {
template: `
<div>
<span>{{count}}</span>
<button @click="changeCount">按钮</button>
</div> `,
data() {
return {
count: 0
}
},
methods: {
changeCount() {
count = this.count++
}
}
})
new Vue({
el: '#app',
// data的值可以是对象
data: {},
methods: {}
});
</script>
</body>
</html>
