53 lines
1.0 KiB
HTML
53 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Document</title>
|
|
</head>
|
|
<body>
|
|
<div id="app">
|
|
<h1>{{data_num}}</h1>
|
|
<apps @item="shower"></apps>
|
|
</div>
|
|
<template id="tpl">
|
|
<div>
|
|
<button @click="add()">+</button>
|
|
<button @click="rev()">-</button>
|
|
</div>
|
|
</template>
|
|
</body>
|
|
<script src="../../../JavaScript/vue.js"></script>
|
|
<script>
|
|
new Vue({
|
|
el:"#app",
|
|
data:{
|
|
data_num:0
|
|
},
|
|
methods: {
|
|
shower(val){
|
|
this.data_num=val
|
|
}
|
|
},
|
|
components:{
|
|
'apps':{
|
|
template:"#tpl",
|
|
data(){
|
|
return {num:0}
|
|
},
|
|
methods: {
|
|
add(){
|
|
this.num+=1
|
|
this.$emit("item",this.num)
|
|
},
|
|
rev(){
|
|
this.num-=1
|
|
this.$emit("item",this.num)
|
|
}
|
|
},
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
</html> |