reactive: 更改可以触发更新
Options
declare reactive state (using the data component option):
1 | export default { |
The message property will be made available(可获得的) in the template:
1 | <h1>{{ message }}</h1> |
Composition
<script setup>
declare reactive state using Vue’s reactive() API:
1 | import { reactive } from 'vue' |
reactive() 只适用于对象(包括数组和 Map 和 Set 等内置类型)
ref() 可以采用任何值类型,并创建一个对象 that exposes the inner value under a .value property:
1 | import { ref } from 'vue' |
更多关于 reactive() and ref() :https://vuejs.org/guide/essentials/reactivity-fundamentals.html