A
A
Alianos2021-04-30 16:26:42
Vue.js
Alianos, 2021-04-30 16:26:42

How to use $refs in watch?

hello i have

watch: {
    "$i18n.locale": (newLang) => {
      somecontext.$refs.selectedLocale.innerHTML = document.querySelector(
        `div[data-locale="${newLang}"]`
      ).innerHTML;
    },
  },

But how can I reach refs from under watch. Context this = undefined. vnode.context unknown how to get...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-04-30
@Alianos

Don't use an arrow function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question