P
P
postya2020-10-20 08:31:30
Vue.js
postya, 2020-10-20 08:31:30

How to get textarea value in Vue?

I have a textarea
component. This component I display on the
v-model page of the texarea gives an empty value and it does not change if I enter something into the textarea.
How can I get the value that I enter into the textarea?

card-textarea.vue:

<template>
  <div class="textarea">
    <textarea
      name="card-textarea"
      id=""
      cols="30"
      :rows="rows"
      :placeholder="placeholder"

    >

    </textarea>
  </div>
</template>

props: {
    placeholder: {
      type: String,
      default: ""
    },
    rows: {
      type: Number,
      default: 5
    },

  }


admin.vue:
<card-textarea
            class="question-card"
            :rows="questionCardRows"
            v-model="questionText"
            :placeholder="questionPlaceholderText"
          >
          </card-textarea>

data: () => ({
questionText: ""
}
methods: {
showText() {
this.questionText;
}
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladlen Hellsite, 2020-10-20
@postya

<template>
  <div class="textarea">
    <textarea
      name="card-textarea"
      id=""
      cols="30"
      :rows="rows"
      :placeholder="placeholder"
      :value="value"
      @input="$emit('input', $event.target.value)"
    >

    </textarea>
  </div>
</template>

props: {
    placeholder: {
      type: String,
      default: ""
    },
    rows: {
      type: Number,
      default: 5
    },
    value: {
       type: String
     }
  }

A
Alexey Yarkov, 2020-10-20
@yarkov Vue.js

That's where you climb, at least once without reading the documentation to the end?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question