0
votes

I can nest components within the root App.vue component just fine but if I try and nest a component within a non root component nothing shows up. If I instead nest the Navbar component that wont show up in Splash.vue within App.vue it works, likewise if I move the Footer component to Splash.vue it doesn't.

App.vue (Footer component works fine, router then loads splash.vue)

<template>
  <div id="app">
      <Footer/>
      <router-view/>
  </div>
</template>

<script>
import Footer from '@/components/Footer'

export default {
  name: 'App',
  components: {
    Footer
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 0px;
}
</style>

Splash.vue (Navbar component doesnt load, the text does load so I know the router is working correctly)

<template>
  <div class="test">
    <v-container fluid>
      <Navbar/>
      <p>splash loaded</p>
    </v-container>
  </div>
</template>

<script>
import Navbar from '@/components/layout/Navbar'

export default {
  name: 'Splash',
  data () {
    return {
      components: {
        Navbar
      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style>
.landing-card-style {
    border-radius: 4px;
    box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14);
}
</style>

main.js

import Vue from 'vue'
import App from './App'
import router from './router'
import Vuetify from 'vuetify'
import 'vuetify/dist/vuetify.min.css'

Vue.use(Vuetify)
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App) 
})

Navbar.vue

<template>
    <div class="navbar">
        <nav class = "deep-purple">
            <div class="container">
                <h1>navbar component loaded</h1>
            </div>
        </nav>
    </div>
</template>

<script>
export default {
    name: 'Navbar',
    data(){
        return{

        }
    }
}
</script>

<style>

</style>
1
Did you try to nest the Navbar outside the v-container component? Also, does it appear when you debug it with Vue Tools?Nikola Kirincic
@niklaz, I think v-container is registered by Vue.use(Vuetify).Harshal Patil
It is within v-container within Splash.vue as in the example, it also shows up as a component within Vue Tools, just doesn't display. Thanks. Edit: Yes I have tried within and outside of v-container, the result is the same.newprogrammer
Can you share Navbar definition?Harshal Patil
I have updated the main postnewprogrammer

1 Answers

3
votes

You have your components inside data() function. Try this instead:

   export default {
      name: 'Splash',
      components: {
        Navbar
      } 
    }