1

I have the following code and i am getting the following error:

Failed to mount component: template or render function not defined.

I want to include top and bottom navigation to the app.vue How can i achieve that?

Main.js:

new Vue({
   el: '#app',
   router,
   template: '<App/>',
   components: { 'App':App }
})

App.vue:

<template>
    <div id="app">
        <navigationtop></navigationtop>
        <navigationbottom></navigationbottom>
        <router-view/>
    </div>
</template>
<script>
    import navigationtop from './components/navigation/top'
    import navigationbottom from './components/navigation/bottom'

    export default {
        name: 'app',
        components: {
            'navigationtop': navigationtop,
            'navigationbottom': navigationbottom
        }
    }......

Router:

export default new Router({
routes: [
  {
    path: '/',
    name: 'HelloWorld',
    component: HelloWorld
  }
 ]
 })

HelloWorld:

<template> </template>
<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'}}}
</script>

enter image description here

4
  • Could you include the code of the components being used at App component? The same for HelloWorld, It's possible that the problem is there. Commented Dec 6, 2017 at 8:20
  • you need rende() method inside your vue object Commented Dec 6, 2017 at 8:47
  • @dlopez updated code Commented Dec 6, 2017 at 9:30
  • @samayo how can i acieve that? Commented Dec 6, 2017 at 9:36

1 Answer 1

2

Try to import your app like this:

import App from './foobar/App.vue'

and render it inside your Vue({}) object like:

new Vue({
   el: '#app',
   router,
   render: h => h(App)
})
Sign up to request clarification or add additional context in comments.

3 Comments

And how can i render the top and bottom navigation?
Vuejs is telling you that the error is coming from ` import navigationbottom from './components/navigation/bottom'` please share the contents of that file
Found it, i had <templat> instead of <template> uhumm sorry and many tnx! Works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.