Issue with passing a placeholder as a prop in a Vue form component

One of the components in my project is the Form Answer component:

<template>
  <div class="flex flex-col items-center justify-center gap-2">
    <!-- <p class="font-semibold">{{ ansLabel }}</p> -->
    <div
      class="flex items-center justify-center gap-5 rounded-3xl border-2 border-gray-300 p-5 shadow-md"
    >
      <textarea class="w-[700px]" :placeholder="ansPlaceholder"> </textarea>
      <input type="checkbox" name="isTrue" id="" />
    </div>
  </div>
</template>

<script setup>
// eslint-disable-next-line no-unused-vars
const props = defineProps({
  ansPlaceholder: {
    type: String,
    default: 'default'
  }
})
</script>

<style scoped></style>

Here's how I implement this component:

<template>
  <div
    name="form container"
    class="mx-2 flex w-[70%] flex-col items-center rounded-3xl border-2 border-black p-3"
  >
    <div
      name="question"
      class="flex w-fit flex-col items-center justify-center gap-3 border-2 border-blue-500 p-3"
    >
      <p class="font-semibold">Question</p>
      <textarea placeholder="Add a question"></textarea>
    </div>
    <div name="answers" class="flex w-fit flex-col gap-5 border-2 border-green-500 p-3">
      <FormAnswer ansPlaceholder="Answer A"></FormAnswer>
      <FormAnswer ansPlaceholder="Answer B"></FormAnswer>
      <FormAnswer ansPlaceholder="Answer C"></FormAnswer>
      <FormAnswer ansPlaceholder="Answer D"></FormAnswer>
      <FormAnswer ansPlaceholder="Answer E"></FormAnswer>
    </div>
  </div>
</template>

<script setup>
import FormAnswer from '../AdminDashboardCmp/FormAnswer.vue'
</script>

<style scoped></style>

However, I encountered an issue with the placeholder not rendering properly as expected. When the page loads, the placeholders for textareas are missing. They only appear after inputting and deleting some text. How can I ensure that the placeholders are visible when the form initially renders?

I attempted to resolve this by adding reactive data and a watcher, but so far it has not been successful.

Answer №1

It appears that there is a space between the opening and closing tags of your textarea element.

The <textarea> tag is unique in that it considers whitespace. If you remove the whitespaces, the textarea will be empty and the placeholder text will be displayed.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What's the deal with the Conditional changeDetectionStrategy in Angular?

I am working with a card component in Angular: https://i.sstatic.net/oCrEx.png One important feature of this card component is the rating stars, which are displayed as a separate component. However, in this specific scenario, the user is unable to inter ...

What is the process for automatically saving associated models when saving the main model?

In my quiz manager, I am working on allowing users to add questions and edit the answers for those questions. My goal is to have a single save button that saves both the questions and their corresponding answers. However, when trying to access and call the ...

Determining the data type of a textbox value in JavaScript: String or Number?

I am encountering an issue with the code below: <input type="text" value="123" id="txtbox"> <script> var myVar = document.getElementById('txtbox').value; if (myVar.substring) { alert('string'); } else{ alert('number&a ...

"Utilizing a custom CSS style for a half heart rating system

I am currently working on implementing a rating system using the font-awesome fa-heart class. While I have successfully colored the full heart, I am facing difficulty in filling only the first half of the heart in red. Despite my research efforts, all solu ...

The rule "react/jsx-sort-props" does not have a valid configuration

I've been attempting to organize props names alphabetically using the eslint-plugin-react plugin but I keep encountering this error: [Error ] .eslintrc.json: Configuration for rule "react/jsx-sort-props" is invalid: Value {"callbacksLast":true,"shorth ...

The compatibility issue between Vue 2.6.12 and Laravel is causing difficulties for FullCalendar to function properly

Recently, I attempted to integrate the fullcalendar library version 5.9.0 into my project following the instructions provided in the documentation. <script> import '@fullcalendar/core/vdom' // resolves Vite issue import FullCalendar from ...

The right-floating div element is not displaying horizontally; instead, it is breaking into a new line

My issue is the dynamically added div elements are not displaying horizontally within a container div element with a specific width. They always break into a new line. Below is the code snippet I am using: var i=1; $(document).ready(function () { ...

Using JavaScript to make API calls with JSON and AJAX

Find type: Procedure : POST Link: http: // beta.etruckingsoft.com:8800/contact/searchContacts INFORMATION: {"Company Id" : 2, "SearchVal" : "b", "Contact Type":"Broker", "token" : "eyJhbGciOiJIUzI1NiJ9.MTkzMA.g132LGIzcwJaJRGa31q-k1hk6u79H0wIj1xjCJzLpZ ...

Converting an object to an array of values in TypeScript: A step-by-step guide

Exploring new features in Angular has led me to encounter a challenge involving Objects and Arrays. Imagine having a customized component called Filter, along with a service named FilterService. Below is the code snippet: filter.component.ts import { Comp ...

Is there a way to connect two circles with identical numbers using Javascript and HTML?

My latest project involves creating a fun program that generates 4 balls on the screen, each with a unique number displayed inside. Users can input their desired values for new circles to be generated and then click a button to see four more balls appear ...

Customize your website with eye-catching full width colored blocks using Bootstrap 3

I am in need of colorful full-width blocks to differentiate the sections on my website. Currently, I am constructing my website with Bootstrap 3 within a standard container. However, I would like certain sections to be vibrant blocks that span across the ...

Load ajax asynchronously once the page has finished loading

I am exploring the world of AJAX with jQuery for the first time, and I am still relatively new to jQuery. Here is the code structure: $(document).ready(function(){ data_url = $('.lazy_content').attr("data-url"); data_id = $( ...

Dealing with jQuery's AJAX time conflicts

I've been tirelessly searching for a solution and spending hours on this issue. Essentially, I'm making an Ajax call to retrieve data from a webpage that in turn fetches data from a database. This particular code is designed for a slideshow featu ...

What is the process for fetching and storing a binary file video in Flask's Blob?

I've been dealing with a video encoding issue for the past few days and I need some help. Objective: Capture a video from my laptop's webcam using a VueJS frontend application. Send this video to a Python Flask app on the backend via FormData u ...

Error converting CSV to JSON format

I prefer using csvtojson converter for transforming data into JSON format. var csvFileName = path; //path== filepath var csvConverter = new Converter(); csvConverter.on("end_parsed", function (jsonObj) { console.log('converted to json object&a ...

JavaScript object value not accessible due to SyntaxError: Unexpected token, expected ,

While working on aliases.js, I encountered an issue when attempting to retrieve the value of the 'SELECT_HOST' property from the imported actionTypes object. This led to a "SyntaxError: Unexpected token, expected ," error according to Webpack. I& ...

Generating exclusion filter based on user input

I am attempting to create a search string that can identify a specific character during the search process. I want to utilize it as an exclusion marker if the text includes the symbol -. The exclusion should only apply when the - character is preceded by ...

Guide for finding the current font of an HTML element

Imagine having a text element styled as follows: font-family: Arial, Verdana, Sans-serif; Is there a way to determine which specific font (Arial, Verdana, or Sans-serif) the browser utilized to display the text? ...

Can you provide a guide on setting up and utilizing mathlive within NuxtJS?

Can anyone assist me? I am trying to figure out why my code is not working or if I have implemented it incorrectly. I used npm i mathlive to obtain input. However, following the instructions for implementing nuxt plugins in the documentation has not yield ...

Most effective method to verify if mutation observer meets specific criteria

I have set up a mutation observer to monitor changes in the page load. Specifically, I am interested in detecting the moment when a particular element is loaded or exists. This element can be identified by its classname, let's say it's called foo ...