Complete the code to declare a prop named title of type String.
<script setup>
const props = defineProps({
title: [1]
})
</script>The title prop should be declared with type String to accept text values.
Complete the code to make the count prop required and of type Number.
<script setup>
const props = defineProps({
count: { type: [1], required: true }
})
</script>required: true.The count prop must be a Number and is marked as required.
Fix the error in the prop validation by completing the validator function to accept only even numbers.
<script setup>
const props = defineProps({
evenNumber: {
type: Number,
validator: value => value [1] 2 === 0
}
})
</script>=== instead of % for the check.The modulo operator % checks if the number is divisible by 2 with no remainder, meaning it is even.
Fill both blanks to declare a status prop with type String and a default value of 'active'.
<script setup>
const props = defineProps({
status: { type: [1], default: [2] }
})
</script>The status prop is a String and defaults to 'active' if not provided.
Fill all three blanks to declare a user prop as an Object with required true and a validator that checks if it has a name property.
<script setup>
const props = defineProps({
user: {
type: [1],
required: [2],
validator: obj => obj && typeof obj.name === [3]
}
})
</script>The user prop is an Object, required, and the validator checks if name is a string.