|
@@ -1,10 +1,47 @@
|
|
|
<!DOCTYPE html>
|
|
<!DOCTYPE html>
|
|
|
<html lang="en">
|
|
<html lang="en">
|
|
|
<head>
|
|
<head>
|
|
|
- <meta charset="UTF-8">
|
|
|
|
|
- <title>$Title$</title>
|
|
|
|
|
|
|
+ <meta charset="UTF-8">
|
|
|
|
|
+ <title>Title</title>
|
|
|
|
|
+ <script src="../vue.js"></script>
|
|
|
</head>
|
|
</head>
|
|
|
<body>
|
|
<body>
|
|
|
-$END$
|
|
|
|
|
|
|
+ <div id="app">
|
|
|
|
|
+ <counter :count="3" @change="handleCount"></counter>
|
|
|
|
|
+ <counter :count="2" @change="handleCount"></counter>
|
|
|
|
|
+ <div>{{total}}</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <script>
|
|
|
|
|
+
|
|
|
|
|
+ var counter = {
|
|
|
|
|
+ props: ["count"],
|
|
|
|
|
+ data: function (){
|
|
|
|
|
+ return {
|
|
|
|
|
+ number: this.count
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ template: '<div @click="handleClick">{{number}}</div>',
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ handleClick: function () {
|
|
|
|
|
+ this.number ++;
|
|
|
|
|
+ this.$emit('change',1)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ var vm = new Vue({
|
|
|
|
|
+ el: "#app",
|
|
|
|
|
+ data: {
|
|
|
|
|
+ total: 5
|
|
|
|
|
+ },
|
|
|
|
|
+ components: {
|
|
|
|
|
+ counter: counter
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ handleCount: function (step){
|
|
|
|
|
+ this.total += step
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ </script>
|
|
|
</body>
|
|
</body>
|
|
|
</html>
|
|
</html>
|