This article shares the specific code for vue dynamic components to implement tab switching for your reference. The specific content is as follows
Navigation buttons:
<div class="tab-title"> <p @click="a='tab1'"><router-link to='/collectnewcars'>New car</router-link><em></em></p> <p @click="a='tab2'"><router-link to='/collectusedcars'>Used cars</router-link><em></em></p> <p @click="a='tab3'"><router-link to='/collectproducts'>Car Products</router-link></p> </div> <div class="tabs"> <component is:="current"></component> </div>
Write 3 subcomponents as
<tab1></tab1> <tab2></tab2> <tab3></tab3>
Use local components to introduce these three subcomponents in js
//Inside the datadata (){ return { a:'tab1' //Default display of tab1 subcomponent } } components:{ 'tab1':tab1, 'tab2':tab2, 'tab3':tab3 }
If you want to pass data from the parent component to these word components, it is the same as the ordinary parent component - "child component. However, if you bind the attribute once in this, you can receive data in each child component, for example:
After defining props:[] in the child component, you can receive the methods and data sent from the parent component.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.