D
D
Darkness2019-08-14 10:23:46
Vue.js
Darkness, 2019-08-14 10:23:46

How to hang dynamic style?

Guys, how to hang the style correctly? To the active "tab" or component ?

p ( class="modalCreate__body-item" @click="switchView('modalCreateTemplate')" :class="{'switch': currentView}") Выбрать шаблон
 p ( class="modalCreate__body-item" @click="switchView('modalCreateContacts')" :class="{'switch': currentView}") Контакт  
// это переключение между компонентами 
 p ( class="modalCreate__body-item" @click="switchView('modalCreateContractors')") Контрагент

component(:is="currentView")  // вывод выбраного компонента

components: {
        modalCreateTemplate,
        modalCreateContacts,
        modalCreateContractors
    },
    methods: {
        switchView (view) {
            this.currentView = view
        }
    }

I tried to do it, but either the style is displayed on all components at once, or it is not displayed at all. The switching logic itself works, I will be grateful for the help!
UPD :
I tried to do it through data. At the same time hanging style if true.
But again, when clicked, styles were hung on all item :c
p(class="modalCreate__body-item" @click="switchView('modalCreateTemplate')" :class="{'switch': switched}") Выбрать шаблон

data {
     switched: false,
},
 methods: {
   switchView (view) {
            this.currentView = view
            this.switched = true
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artur Karapetyan, 2019-08-14
@AntonBrock

p ( class="modalCreate__body-item" @click="switchView('modalCreateTemplate')" :class="{'switch': currentView === 'modalCreateTemplate'}") Выбрать шаблон
Контрагент
?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question