A
A
Andrew2018-12-15 23:20:54
Vue.js
Andrew, 2018-12-15 23:20:54

Component inside vue component?

I have a Main component. It has a Sidebar component. For each page, the contents of the Sidebar should be different, so I created separate components for each to place them on the right pages.
In the main component, I register them:

import MiddleBar from '@/components/Main/MiddleBar/MiddleBar'
import Streams from '@/components/Main/MiddleBar/Elements/Streams'

export default {
  components: {
    MiddleBar,
    Streams
  }
}

And I try to insert them (Pug syntax): Nothing works. I can't figure out what's wrong. I didn't find anything in the documentation about component nesting. :( Especially on pug.
| <MiddleBar> <Streams></Streams> </MiddleBar>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
shmatuan, 2018-12-15
@AndrewRusinas

https://en.vuejs.org/v2/guide/components.html#Spread...

S
Serhii Karavashkin, 2020-04-20
@ksawl

you need to leave in the main component like this

import MiddleBar from '@/components/Main/MiddleBar/MiddleBar'

export default {
  components: {
    MiddleBar
  }
}

and in the MiddleBar component do like this
import Streams from '@/components/Main/MiddleBar/Elements/Streams'

export default {
  components: {
    Streams
  }
}

and so you can invest indefinitely

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question