Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
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.