Vue - Unable to render component










0















Some components cannot be injected into the App.vue template. Particularly, the Login.vue is the one that is causing issues. If I create it from scratch while the server is running (npm run dev) it will work, but once I restart it and navigate to the Login component, it will fail to load.



Stack Trace



[Vue warn]: Failed to mount component: template or render function not defined.

found in

---> <Login>
<App> at src/App.vue
<Root>


src/components/Login.vue



<template>
<div id="login">
<ul>
<li><input type="text" v-model="username" placeholder="Username"></li>
<li><input type="password" v-model="password" placeholder="Password"></li>
<li><button @click="login(username, password)">Login</button></li>
</ul>
</div>
</template>

<script>
</script>

<style scoped>

#login
padding-top: 100px;


ul
list-style-type: none;
padding: 0;


li
display: inline-block;
margin: 0 10px;


</style>


src/router/index.js



import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'
import RideSharing from '@/components/RideSharing'
import Login from '@/components/Login'
import About from '@/components/About'

Vue.use(Router)

export default new Router(
routes: [

path: '/',
name: 'Hello',
component: Hello
,

path: '/app',
name: 'RideSharing',
component: RideSharing
,

path: '/app/login',
name: 'Login',
component: Login
,

path: '/app/about',
name: 'About',
component: About

]
)


src/App.vue



<template>
<div id="app" :style="padding: $route.path === '/' ? '172px' : '10px'">
<div>
<img src="./assets/logo4.png" align="center">
</div>
<router-view></router-view>
</div>
</template>

<script>
export default
name: 'app'

</script>

<style>
#app
font-family: 'Avenir', Helvetica, Arial, sans-serif;
background-color: hsla(269, 96%, 50%, 0.73);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 0px;
height: inherit;


body
height: inherit;


html
height: 100%;

</style>


src/main.js



// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import BootstrapVue from "bootstrap-vue"
import App from './App'
import router from './router'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

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

/* eslint-disable no-new */
new Vue(
el: '#app',
router,
template: '<App/>',
components: App
)









share|improve this question



















  • 1





    can you share the login.js file?

    – Efrat
    Nov 15 '18 at 21:56











  • Shouldn't the Login component be contained in the App?

    – zavtra
    Nov 15 '18 at 22:05











  • Then why do you have: <script src="./login.js">? That would suggest an outside file login.js.

    – Jayem163
    Nov 15 '18 at 22:12











  • @Efrat Sorry, I forgot to omit that part. The login.js file was empty and wasn’t the source of the issue.

    – Noam Suissa
    Nov 15 '18 at 23:14











  • @Jayem163 script pointer shouldn’t have been there. Edited the code

    – Noam Suissa
    Nov 15 '18 at 23:17















0















Some components cannot be injected into the App.vue template. Particularly, the Login.vue is the one that is causing issues. If I create it from scratch while the server is running (npm run dev) it will work, but once I restart it and navigate to the Login component, it will fail to load.



Stack Trace



[Vue warn]: Failed to mount component: template or render function not defined.

found in

---> <Login>
<App> at src/App.vue
<Root>


src/components/Login.vue



<template>
<div id="login">
<ul>
<li><input type="text" v-model="username" placeholder="Username"></li>
<li><input type="password" v-model="password" placeholder="Password"></li>
<li><button @click="login(username, password)">Login</button></li>
</ul>
</div>
</template>

<script>
</script>

<style scoped>

#login
padding-top: 100px;


ul
list-style-type: none;
padding: 0;


li
display: inline-block;
margin: 0 10px;


</style>


src/router/index.js



import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'
import RideSharing from '@/components/RideSharing'
import Login from '@/components/Login'
import About from '@/components/About'

Vue.use(Router)

export default new Router(
routes: [

path: '/',
name: 'Hello',
component: Hello
,

path: '/app',
name: 'RideSharing',
component: RideSharing
,

path: '/app/login',
name: 'Login',
component: Login
,

path: '/app/about',
name: 'About',
component: About

]
)


src/App.vue



<template>
<div id="app" :style="padding: $route.path === '/' ? '172px' : '10px'">
<div>
<img src="./assets/logo4.png" align="center">
</div>
<router-view></router-view>
</div>
</template>

<script>
export default
name: 'app'

</script>

<style>
#app
font-family: 'Avenir', Helvetica, Arial, sans-serif;
background-color: hsla(269, 96%, 50%, 0.73);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 0px;
height: inherit;


body
height: inherit;


html
height: 100%;

</style>


src/main.js



// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import BootstrapVue from "bootstrap-vue"
import App from './App'
import router from './router'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

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

/* eslint-disable no-new */
new Vue(
el: '#app',
router,
template: '<App/>',
components: App
)









share|improve this question



















  • 1





    can you share the login.js file?

    – Efrat
    Nov 15 '18 at 21:56











  • Shouldn't the Login component be contained in the App?

    – zavtra
    Nov 15 '18 at 22:05











  • Then why do you have: <script src="./login.js">? That would suggest an outside file login.js.

    – Jayem163
    Nov 15 '18 at 22:12











  • @Efrat Sorry, I forgot to omit that part. The login.js file was empty and wasn’t the source of the issue.

    – Noam Suissa
    Nov 15 '18 at 23:14











  • @Jayem163 script pointer shouldn’t have been there. Edited the code

    – Noam Suissa
    Nov 15 '18 at 23:17













0












0








0








Some components cannot be injected into the App.vue template. Particularly, the Login.vue is the one that is causing issues. If I create it from scratch while the server is running (npm run dev) it will work, but once I restart it and navigate to the Login component, it will fail to load.



Stack Trace



[Vue warn]: Failed to mount component: template or render function not defined.

found in

---> <Login>
<App> at src/App.vue
<Root>


src/components/Login.vue



<template>
<div id="login">
<ul>
<li><input type="text" v-model="username" placeholder="Username"></li>
<li><input type="password" v-model="password" placeholder="Password"></li>
<li><button @click="login(username, password)">Login</button></li>
</ul>
</div>
</template>

<script>
</script>

<style scoped>

#login
padding-top: 100px;


ul
list-style-type: none;
padding: 0;


li
display: inline-block;
margin: 0 10px;


</style>


src/router/index.js



import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'
import RideSharing from '@/components/RideSharing'
import Login from '@/components/Login'
import About from '@/components/About'

Vue.use(Router)

export default new Router(
routes: [

path: '/',
name: 'Hello',
component: Hello
,

path: '/app',
name: 'RideSharing',
component: RideSharing
,

path: '/app/login',
name: 'Login',
component: Login
,

path: '/app/about',
name: 'About',
component: About

]
)


src/App.vue



<template>
<div id="app" :style="padding: $route.path === '/' ? '172px' : '10px'">
<div>
<img src="./assets/logo4.png" align="center">
</div>
<router-view></router-view>
</div>
</template>

<script>
export default
name: 'app'

</script>

<style>
#app
font-family: 'Avenir', Helvetica, Arial, sans-serif;
background-color: hsla(269, 96%, 50%, 0.73);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 0px;
height: inherit;


body
height: inherit;


html
height: 100%;

</style>


src/main.js



// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import BootstrapVue from "bootstrap-vue"
import App from './App'
import router from './router'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

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

/* eslint-disable no-new */
new Vue(
el: '#app',
router,
template: '<App/>',
components: App
)









share|improve this question
















Some components cannot be injected into the App.vue template. Particularly, the Login.vue is the one that is causing issues. If I create it from scratch while the server is running (npm run dev) it will work, but once I restart it and navigate to the Login component, it will fail to load.



Stack Trace



[Vue warn]: Failed to mount component: template or render function not defined.

found in

---> <Login>
<App> at src/App.vue
<Root>


src/components/Login.vue



<template>
<div id="login">
<ul>
<li><input type="text" v-model="username" placeholder="Username"></li>
<li><input type="password" v-model="password" placeholder="Password"></li>
<li><button @click="login(username, password)">Login</button></li>
</ul>
</div>
</template>

<script>
</script>

<style scoped>

#login
padding-top: 100px;


ul
list-style-type: none;
padding: 0;


li
display: inline-block;
margin: 0 10px;


</style>


src/router/index.js



import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello'
import RideSharing from '@/components/RideSharing'
import Login from '@/components/Login'
import About from '@/components/About'

Vue.use(Router)

export default new Router(
routes: [

path: '/',
name: 'Hello',
component: Hello
,

path: '/app',
name: 'RideSharing',
component: RideSharing
,

path: '/app/login',
name: 'Login',
component: Login
,

path: '/app/about',
name: 'About',
component: About

]
)


src/App.vue



<template>
<div id="app" :style="padding: $route.path === '/' ? '172px' : '10px'">
<div>
<img src="./assets/logo4.png" align="center">
</div>
<router-view></router-view>
</div>
</template>

<script>
export default
name: 'app'

</script>

<style>
#app
font-family: 'Avenir', Helvetica, Arial, sans-serif;
background-color: hsla(269, 96%, 50%, 0.73);
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 0px;
height: inherit;


body
height: inherit;


html
height: 100%;

</style>


src/main.js



// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import BootstrapVue from "bootstrap-vue"
import App from './App'
import router from './router'
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

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

/* eslint-disable no-new */
new Vue(
el: '#app',
router,
template: '<App/>',
components: App
)






javascript html vue.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 23:15







Noam Suissa

















asked Nov 15 '18 at 21:43









Noam SuissaNoam Suissa

236




236







  • 1





    can you share the login.js file?

    – Efrat
    Nov 15 '18 at 21:56











  • Shouldn't the Login component be contained in the App?

    – zavtra
    Nov 15 '18 at 22:05











  • Then why do you have: <script src="./login.js">? That would suggest an outside file login.js.

    – Jayem163
    Nov 15 '18 at 22:12











  • @Efrat Sorry, I forgot to omit that part. The login.js file was empty and wasn’t the source of the issue.

    – Noam Suissa
    Nov 15 '18 at 23:14











  • @Jayem163 script pointer shouldn’t have been there. Edited the code

    – Noam Suissa
    Nov 15 '18 at 23:17












  • 1





    can you share the login.js file?

    – Efrat
    Nov 15 '18 at 21:56











  • Shouldn't the Login component be contained in the App?

    – zavtra
    Nov 15 '18 at 22:05











  • Then why do you have: <script src="./login.js">? That would suggest an outside file login.js.

    – Jayem163
    Nov 15 '18 at 22:12











  • @Efrat Sorry, I forgot to omit that part. The login.js file was empty and wasn’t the source of the issue.

    – Noam Suissa
    Nov 15 '18 at 23:14











  • @Jayem163 script pointer shouldn’t have been there. Edited the code

    – Noam Suissa
    Nov 15 '18 at 23:17







1




1





can you share the login.js file?

– Efrat
Nov 15 '18 at 21:56





can you share the login.js file?

– Efrat
Nov 15 '18 at 21:56













Shouldn't the Login component be contained in the App?

– zavtra
Nov 15 '18 at 22:05





Shouldn't the Login component be contained in the App?

– zavtra
Nov 15 '18 at 22:05













Then why do you have: <script src="./login.js">? That would suggest an outside file login.js.

– Jayem163
Nov 15 '18 at 22:12





Then why do you have: <script src="./login.js">? That would suggest an outside file login.js.

– Jayem163
Nov 15 '18 at 22:12













@Efrat Sorry, I forgot to omit that part. The login.js file was empty and wasn’t the source of the issue.

– Noam Suissa
Nov 15 '18 at 23:14





@Efrat Sorry, I forgot to omit that part. The login.js file was empty and wasn’t the source of the issue.

– Noam Suissa
Nov 15 '18 at 23:14













@Jayem163 script pointer shouldn’t have been there. Edited the code

– Noam Suissa
Nov 15 '18 at 23:17





@Jayem163 script pointer shouldn’t have been there. Edited the code

– Noam Suissa
Nov 15 '18 at 23:17












2 Answers
2






active

oldest

votes


















0














If you are using the full build version of Vue then you could try to mount the DOM template using .$mount('#app')



So, in your main.js, your app script would look like this:



new Vue(
router,
template: '<App/>',
components: App ,
).$mount('#app')





share|improve this answer























  • this did not work

    – Noam Suissa
    Nov 16 '18 at 0:22


















0














SOLUTION:



Missing .vue extensions in imports.



src/router/index.js



import Vue from 'vue'
import Router from 'vue-router'
import Hello from '@/components/Hello.vue'
import RideSharing from '@/components/RideSharing.vue'
import Login from '@/components/Login.vue'
import About from '@/components/About.vue'





share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328307%2fvue-unable-to-render-component%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If you are using the full build version of Vue then you could try to mount the DOM template using .$mount('#app')



    So, in your main.js, your app script would look like this:



    new Vue(
    router,
    template: '<App/>',
    components: App ,
    ).$mount('#app')





    share|improve this answer























    • this did not work

      – Noam Suissa
      Nov 16 '18 at 0:22















    0














    If you are using the full build version of Vue then you could try to mount the DOM template using .$mount('#app')



    So, in your main.js, your app script would look like this:



    new Vue(
    router,
    template: '<App/>',
    components: App ,
    ).$mount('#app')





    share|improve this answer























    • this did not work

      – Noam Suissa
      Nov 16 '18 at 0:22













    0












    0








    0







    If you are using the full build version of Vue then you could try to mount the DOM template using .$mount('#app')



    So, in your main.js, your app script would look like this:



    new Vue(
    router,
    template: '<App/>',
    components: App ,
    ).$mount('#app')





    share|improve this answer













    If you are using the full build version of Vue then you could try to mount the DOM template using .$mount('#app')



    So, in your main.js, your app script would look like this:



    new Vue(
    router,
    template: '<App/>',
    components: App ,
    ).$mount('#app')






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 15 '18 at 22:15









    CUGreenCUGreen

    2,0001512




    2,0001512












    • this did not work

      – Noam Suissa
      Nov 16 '18 at 0:22

















    • this did not work

      – Noam Suissa
      Nov 16 '18 at 0:22
















    this did not work

    – Noam Suissa
    Nov 16 '18 at 0:22





    this did not work

    – Noam Suissa
    Nov 16 '18 at 0:22













    0














    SOLUTION:



    Missing .vue extensions in imports.



    src/router/index.js



    import Vue from 'vue'
    import Router from 'vue-router'
    import Hello from '@/components/Hello.vue'
    import RideSharing from '@/components/RideSharing.vue'
    import Login from '@/components/Login.vue'
    import About from '@/components/About.vue'





    share|improve this answer



























      0














      SOLUTION:



      Missing .vue extensions in imports.



      src/router/index.js



      import Vue from 'vue'
      import Router from 'vue-router'
      import Hello from '@/components/Hello.vue'
      import RideSharing from '@/components/RideSharing.vue'
      import Login from '@/components/Login.vue'
      import About from '@/components/About.vue'





      share|improve this answer

























        0












        0








        0







        SOLUTION:



        Missing .vue extensions in imports.



        src/router/index.js



        import Vue from 'vue'
        import Router from 'vue-router'
        import Hello from '@/components/Hello.vue'
        import RideSharing from '@/components/RideSharing.vue'
        import Login from '@/components/Login.vue'
        import About from '@/components/About.vue'





        share|improve this answer













        SOLUTION:



        Missing .vue extensions in imports.



        src/router/index.js



        import Vue from 'vue'
        import Router from 'vue-router'
        import Hello from '@/components/Hello.vue'
        import RideSharing from '@/components/RideSharing.vue'
        import Login from '@/components/Login.vue'
        import About from '@/components/About.vue'






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 16 '18 at 1:14









        Noam SuissaNoam Suissa

        236




        236



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328307%2fvue-unable-to-render-component%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            27

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            Category:Rhetoric