Can not take input value from javascript

I have a input element and I want to get its value from javascript, can I just use native DOM manipulation for this ?


          <div class="comment__reply-text">
            <input id="formValueId" type="text" placeholder="Cevabınızı buraya yazınız.." class="comment__entry"
                   v-model="this.answerName">
            <span v-on:click="sendComment()" class="comment__reply-text--ico">
                <svg-icon type="icon-send"/>
            </span>
          </div>
  methods: {
    sendComment: function () {
      var value =  text.form.valueId.value;
      console.log("send comment: " + value)
      axios.post(`/site/dorm/comment/${this.id}`, {
        data: value
      })
    },

I also tried this

methods: {
    var value =  text.valueId.value;

I found a solution

console.log(this.$refs.myTestField.value)

topic can be deleted

Why are you not using v-model to access your input field data?

2 Likes

You are right, I see its used in the project I attented. So is it better to use v-model instead of pure DOm maniulation ? another thins is sometimes I need to add event listener, can I do on varibles that I get via -model ?