Complete the code to bind user input to a reactive variable in Vue.
<template> <input v-model="userInput" placeholder="Enter text" /> <p>User input: {{ userInput }}</p> </template> <script setup> import { ref } from 'vue' const userInput = [1]('') </script>
In Vue 3, ref creates a reactive variable that can be bound to inputs with v-model.
Complete the code to sanitize user input by trimming whitespace before saving.
<script setup> import { ref } from 'vue' const userInput = ref('') function updateInput(value) { userInput.value = value.[1]() } </script>
The trim() method removes whitespace from both ends of a string, helping sanitize input.
Fix the error in the code that tries to sanitize input by escaping HTML tags.
<script setup> import { ref } from 'vue' const userInput = ref('') function sanitizeInput(value) { return value.replace(/[1]/g, '<') } </script>
The regex should match the less-than sign < to escape HTML tags properly.
Fill both blanks to create a computed property that returns sanitized user input.
<script setup> import { ref, computed } from 'vue' const rawInput = ref('') const sanitizedInput = computed(() => rawInput.value.[1]().replace(/[2]/g, '<')) </script>
First, trim whitespace, then replace the less-than sign to escape HTML tags.
Fill all three blanks to create a method that sanitizes input by trimming, escaping < and >, and converting to lowercase.
<script setup> import { ref } from 'vue' const userInput = ref('') function sanitize(value) { return value.[1]().replace(/[2]/g, '<').replace(/[3]/g, '>').toLowerCase() } </script>
Trim removes spaces, then replace < and > to escape HTML tags, finally convert to lowercase for uniformity.