Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bfaaeb8

Browse filesBrowse files
committed
✨ 球和案例
1 parent 84e7108 commit bfaaeb8
Copy full SHA for bfaaeb8

File tree

Expand file treeCollapse file tree

3 files changed

+56
-18
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+56
-18
lines changed
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
<template>
22
<div id="app">
3-
<Demo1 />
3+
<!-- <Demo1 />
44
<hr />
55
<Demo2 />
66
<hr />
7-
<Demo3 />
7+
<Demo3 /> -->
8+
<Demo4 />
89
</div>
910
</template>
1011

1112
<script>
12-
import Demo1 from "@/views/demo1/index.vue";
13-
import Demo2 from "@/views/demo2/index.vue";
14-
import Demo3 from "@/views/demo3/index.vue";
13+
// import Demo1 from "@/views/demo1/index.vue";
14+
// import Demo2 from "@/views/demo2/index.vue";
15+
// import Demo3 from "@/views/demo3/index.vue";
16+
import Demo4 from "@/views/demo4/index.vue";
1517
1618
export default {
1719
name: "App",
18-
components: { Demo1, Demo2, Demo3 },
20+
// components: { Demo1, Demo2, Demo3 },
21+
components: { Demo4 },
1922
};
2023
</script>

‎vue2-tutorials/single-file/demo2/src/views/demo4/compontens/Count.vue

Copy file name to clipboardExpand all lines: vue2-tutorials/single-file/demo2/src/views/demo4/compontens/Count.vue
+34-10Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
<template>
22
<div>
3-
<h1>当前求和为:???</h1>
4-
<select>
5-
<option value="1">1</option>
6-
<option value="2">2</option>
7-
<option value="3">3</option>
3+
<h1>当前求和为:{{ sum }}</h1>
4+
<select v-model.number="num">
5+
<option :value="1">1</option>
6+
<option :value="2">2</option>
7+
<option :value="3">3</option>
88
</select>
99

10-
<button>+</button>
11-
<button>-</button>
12-
<button>-当前求和为奇数再加</button>
13-
<button>-等一等再加</button>
10+
<button @click="increment">+</button>
11+
<button @click="decrement">-</button>
12+
<button @click="incrementOdd">当前求和为奇数再加</button>
13+
<button @click="incrementWait">等一等再加</button>
1414
</div>
1515
</template>
1616

1717
<script>
1818
export default {
19-
name: "Count",
19+
name: "CountInfo",
20+
data() {
21+
return {
22+
num: 1,
23+
sum: 0,
24+
};
25+
},
26+
methods: {
27+
increment() {
28+
this.sum += this.num;
29+
},
30+
decrement() {
31+
this.sum -= this.num;
32+
},
33+
incrementOdd() {
34+
if (this.sum % 2) {
35+
this.sum += this.num;
36+
}
37+
},
38+
incrementWait() {
39+
setTimeout(() => {
40+
this.sum += this.num;
41+
}, 500);
42+
},
43+
},
2044
};
2145
</script>
2246

+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
<template></template>
1+
<template>
2+
<Count />
3+
</template>
24

3-
<script></script>
5+
<script>
6+
import Count from "./compontens/Count.vue";
7+
8+
export default {
9+
name: "Demo-4",
10+
components: {
11+
Count,
12+
},
13+
};
14+
</script>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.