File tree 1 file changed +33
-9
lines changed
1 file changed +33
-9
lines changed Original file line number Diff line number Diff line change
1
+ <template >
2
+ <div class =" home" >
3
+ <img alt =" Vue logo" src =" ../assets/logo.png" />
4
+ <p >{{ count }}</p >
5
+ <button @click =" incrementCount" >Add</button >
6
+ </div >
7
+ </template >
8
+
1
9
<script >
2
- import BackgroundFunction from ' ../components/BackgroundFunction. vue'
10
+ import { reactive , toRefs , watch } from ' vue'
3
11
4
12
export default {
5
- components: {
6
- BackgroundFunction
13
+ name: ' Home' ,
14
+ setup () {
15
+ const state = reactive ({
16
+ count: 0
17
+ })
18
+
19
+ const incrementCount = () => {
20
+ state .count ++
21
+ }
22
+
23
+ watch (
24
+ () => state .count ,
25
+ (currentValue , oldValue ) => {
26
+ console .log (' current' , currentValue)
27
+ console .log (' old' , oldValue)
28
+ }
29
+ )
30
+
31
+ const
32
+
33
+ return {
34
+ ... toRefs (state),
35
+ incrementCount
36
+ }
7
37
}
8
38
}
9
39
</script >
10
-
11
- <template >
12
- <background-function />
13
- </template >
14
-
15
- <style ></style >
You can’t perform that action at this time.
0 commit comments