Complete the code to define a reactive data property in the Options API.
export default {
data() {
return {
message: [1]
};
}
}In the Options API, reactive data properties are defined as plain values inside the data() function's return object.
Complete the code to create a reactive variable using the Composition API.
<script setup> import { [1] } from 'vue'; const count = [1](0); </script>
The ref function creates a reactive variable in the Composition API.
Fix the error in the Options API method to correctly access data property.
export default {
data() {
return {
count: 0
};
},
methods: {
increment() {
this.[1]++;
}
}
}this.this.count or calling count as a function.Inside methods, this refers to the component instance, so this.count is correct. But since this is already used, just use count without this causes error. Actually, in Vue Options API, you must use this.count. So correct answer is count or this.count? The code says this.{{BLANK_1}}++; so the blank is after this. so the blank should be count.
Fill both blanks to create a computed property in the Composition API.
<script setup> import { [1] } from 'vue'; const count = ref(0); const double = [2](() => count.value * 2); </script>
The computed function is imported and used to create computed properties in the Composition API.
Fill all three blanks to define a reactive object and a method to update it in the Composition API.
<script setup> import { [1], [2] } from 'vue'; const state = [3]({ count: 0 }); function increment() { state.count++; } </script>
To create a reactive object, import reactive. The watch import is extra here but included as distractor. The reactive object is created with reactive().