setAttribute doesn't work in v-onsen
-
I wish to toggle the type attribute in a <v-ons-input> from “password” to “text” but the console show this error:
The App.vue code:
and the Password.vue component:
When I use “getAttribute” or “hasAtributte” the same thing happens.
In pure Vue code it doesn’t produce errors, it works fine, the type toggle correctly.
-
@buscemi To begin with, I think it’s easier if you use
:type="type"
as a prop in your template instead of getting DOM elements and modifying them :sweat_smile:If you don’t want to do that, well, I guess your reference is getting a Vue element (v-ons-input), which is not a real DOM input. Try
this.$refs.input.$el.setAttribute
instead.
-
@Fran-Diox The second solution works fine. Thanks for your suggestions.