I am new to Vue and I am trying a couple of basic examples to understand the framework. I have created 2 single file components navigation.vue and pageoptions.vue. I have imported them in the main.js file and I am able to successfully compile and run the application. However though I have both the components in the index.html (inside "app") only 1 component is rendered, i.e. the 1 that I pass to the render function. Since the render function cannot return multiple elements, how do I get any other component render on the page without clubbing these 2 components in 1 parent component? If this is not supported, then what is the way to address this scenario? Where am I wrong?
Component 1 - navigation.vue
<template>
<div>Navigation Menu</div>
</template>
<script>
export default {
name: 'navigation',
data () {
return {
}
}
}
</script>
Component 2 - pageoptions.vue
<template>
<div>Page Options</div>
</template>
<script>
export default {
name: 'pageoptions',
data () {
return {
}
}
}
</script>
main.js file
import Vue from 'vue'
import navigation from './components/navigation.vue'
import pageoptions from './components/pageoptions.vue'
new Vue({
el: '#app',
render: (element => element(navigation)),//this will render only navigation component. How to render pageoptions too in this call?
components: {navigation,pageoptions}
})
index.html
<!--html, head, body etc-->
<div id="app">
<div style="background-color:teal;">
<navigation></navigation>
</div>
<div style="background-color:silver">
<pageoptions></pageoptions>
</div>
</div>
<!--html, head, body etc-->
Output in browser
Navigation Menu