reactive API的使用
# reactive API的使用
<template>
<div>{{ state.content }} <button @click="add">点击</button></div>
</template>
<script>
import { reactive } from "vue";
export default {
setup(props, { attrs, slots, emit }) {
const state = reactive({
content: 0,
});
const add = () => {
state.content++;
};
return {
add,
state,
};
},
};
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22