2

I have an input whose model property is beeing watched. The problem is that the watch method is not called on every key press in Chrome Android devices. If I tap the input text, then it gets called. It did worked in the past and I don't know what happened. On Chrome Desktop it works (that is: the watch for text is beeing called on every keypress).

Input:

  <input id="input-message" ref="input-message" :disabled="disabled"
  @focus="$emit('focus')" @keyup.enter="sendMessage" 
  v-model="text" type="text" placeholder="Start typing..." 
  class="form-control">

Watch:

  watch: {
    disabled: function(val) {
      if (!val) {
        this.$nextTick(() => {
          this.$refs["input-message"].focus();
        });
      }
    },
    text: function(val) {
      var mode = this.micMode;
      if (this.userAgent !== "ios") {
        let isEmpty = val.length === 0;

        if (mode === 1 && !isEmpty) {
          this.micMode = 0;
        } else if (mode === 0 && isEmpty) {
          this.micMode = 1;
        }
      }

    }
  },
0

1 Answer 1

8

For languages that require an IME (Chinese, Japanese, Korean etc.), you’ll notice that v-model doesn’t get updated during IME composition. If you want to cater for these updates as well, use input event instead.

https://v2.vuejs.org/v2/guide/forms.html#vmodel-ime-tip

you can change v-model="model" to :value="text" @input="text = $event.target.value" and the watcher should be triggered as expected

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.