V
V
Varcbv2021-10-31 12:01:54
Vue.js
Varcbv, 2021-10-31 12:01:54

How to change the style of an element in one component if the button was clicked in another component?

Who can suggest how to change the style of an element in one component if the button was clicked in another component?
Here is the button in the Aside component

a(href='#' @click='showMobileMenu = !showMobileMenu')
import { defineComponent } from 'vue'
export default defineComponent({
  data () {
    return {
      showMobileMenu: false
    }
  },

and here is another component
<template lang="pug">
.asd
    Nav
    Section
</template>

<script lang="ts">
import { Options, Vue } from 'vue-class-component'
import Nav from '@/components/Nav.vue' // @ is an alias to /src
import Section from '@/components/Section.vue' // @ is an alias to /src
@Options({
  components: {
    Nav,
    Section
  }
})

export default class Home extends Vue {}
</script>

<style lang="scss">
</style>

in which you need to make sure that .asd is also active / inactive

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question