3

I would like to be able to dynamically change the type of an input field between text and password. I tried doing the following:

<input :type="dynamicInputType">

data() {
    return {
        dynamicInputType: 'password'
    }
}

But apparently this doesn't work; vuejs displays the error: v-model does not support dynamic input types. Use v-if branches instead.

It's not clear to me how I can fix this with v-if.

1 Answer 1

3

This kind of thing is what's being suggested.

<input v-if="'text' === dynamicInputType" type="text">
<input v-else type="password">
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.