Answer the question
In order to leave comments, you need to log in
How to combine inserted() + dynamic?
Hello, I'm trying to create a language-dropdown but since it should select a default value, I need inserted to change the text of the default language name, but I also need the text of the selected language to change when the language selection changes. I would very much like it to depend only on the $i18n.locale variable.
Now I use such a crutch of two directives
selectedLocaleFirst: {
inserted(el, binding, vnode) {
el.innerHTML = document.querySelector(
`div[data-locale="${vnode.context.$i18n.locale}"]`
).innerHTML;
},
},
selectedLocaleDynamic(el, binding, vnode) {
el.innerHTML = document.querySelector(
`div[data-locale="${vnode.context.$i18n.locale}"]`
).innerHTML;
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question