Answer the question
In order to leave comments, you need to log in
How to bulk initialize dropdown in vue?
Hello.
vue + materializecss. I display blocks with dropdown in a loop.
<a class="" href="#" :ref="'dropdown' + post.index" v-bind:data-target="'dropdown' + post.index" > <i class="material-icons">visibility</i></a>
<ul v-bind:id="'dropdown' + post.index" class="dropdown-content">
<li>...</li>
</ul>
mounted() {
M.Dropdown.init( this.$refs.dropdow?, {
hover: true
})
},
Answer the question
In order to leave comments, you need to log in
Stupid variant: as in a cycle deduce, so in a cycle initialize (at v-for
in this.$refs.dropdow
the array lies).
The correct option is to make a separate component m-dropdown
, which inside carries out all the necessary initialization and arranges the necessary layout, and then connect this particular component in a loop.
Ideal option: use libs written in vue in order to avoid unnecessary overhead.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question