1

There is a input tag in vue template. I want to use 'text' type not 'password' type.

  <input type="text" v-model="form.password" />

So I made a watch code to change text string to ** string.

  watch: {
    "form.password": function(val) {
      this.form.password = *
    }
  }

But when I type one character it is changed to ' * ' , so 'watch' caches again and again infinitely.
How can I solve this problem? Thank you so much for reading it.

1 Answer 1

1

You can solve your watch problem by using the input event instead, which only gets fired when you type something.

<input type="text" :value="form.password" @input="updatePassword" />

Then in your method

methods: {
    updatePassword: function(ev) {
        this.form.password = "*";
    }
}
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.