vuejs - dynamic input 'types'

Viewed 994

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 Answers
Related