I want to create a component in my components file, and then include this (like ng-include used to) in my base app.
my App.vue looks like this:
<template>
<div id="app">
<div class="container-fluid">
<div class="row>
<navigation></navigation>
</div>
<div class="row">
<router-view></router-view>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'app',
}
</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: 60px;
}
</style>
And my main.js file looks like this:
import Vue from 'vue'
import App from './App'
import VueRouter from 'vue-router'
import homepage from './components/homepage'
import navigation from './components/navigation'
Vue.use(VueRouter)
const routes = [
{ path: '/', component: homepage}
]
const router = new VueRouter({
routes,
mode: 'history'
})
new Vue({
el: '#app',
template: '<App/>',
components: {
App, navigation
},
router
}).$mount('#app')
navigation.vue:
<template>
<div>
<p>test</p>
</div>
</template>
<script>
export default {
name: 'navigation'
}
</script>
When I run the above I get:
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
found in
---> at src/App.vue
I know how to add a vue.component, but i what I want is an external component, like the homepage, pulled from the components folder, and included in the base app.