Vue · Junior · Question 13 of 75
How do you declare reactive state in <script setup>?
const count = ref(0);
function increment() {
count.value++;
}- ✓Correct answer: With
ref(); in JavaScript you read and write.value, in the template you usecountdirectly - 2With a plain
let count = 0, Vue tracks all variables automatically - 3With
this.count = 0
Explanation
ref wraps a value in an object with a reactive .value property. Top-level refs are automatically unwrapped in templates, so you write {{ count }}.