S
S
stanislavkm2022-04-16 22:49:55
Vue.js
stanislavkm, 2022-04-16 22:49:55

Set body class when variable is active in vue?

How to refer to body in vue?
If the showMobileMenu variable is set to true, you need to add a class to the body. How - I understand where - no.
:class="showMobileMenu ? '_lock' :''"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2022-04-16
@stanislavkm

watch: {
  переменная: {
    immediate: true,
    handler(val) {
      document.body.classList.toggle('класс', val);
    },
  },
},

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question