0

I created my first Vue app and I have a problem with the router. I have 3 components first 2 works perfectly but 3 doesn't. Here is my code:

index.js

import Vue from 'vue'
import Router from 'vue-router'
import Homepage from '@/components/Homepage'
import Login from '@/components/Login'
import Register from '@/components/Register'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Homepage',
      component: Homepage
    },
    {
      path: '/account/login',
      name: 'Login',
      component: Login
    },
    {
      path: '/account/register',
      name: 'Register',
      compontent: Register
    }
  ]
})

Register.vue

<template>
  <div class="hello">
    <h2>This is test</h2>
  </div>
</template>

<script>
import Vue from 'vue'
export default {
  name: 'Register',
  data () {
    return {
      username: '',
      email: '',
      password: ''
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

I don't know what I'm doing wrong. I tried to use Register.vue in login rout and it worked. What I'm doing wrong? Thanks in advance for the help!

If it matters I run sever by npm run dev.

7
  • Do you have any error log? What happens when you visit /account/register directly by entering url to browser? Commented May 20, 2018 at 15:30
  • I have a blank white page without any error in console. Commented May 20, 2018 at 15:40
  • Is your Register.vue file in the right directory? Commented May 20, 2018 at 16:45
  • @JegadeshBS Yeah I have it in same directory as Login and Homepage Commented May 20, 2018 at 17:09
  • @xaos_xv why are you importing Vue again in the component(Register.vue) ? Commented May 20, 2018 at 17:19

1 Answer 1

3

Rename the property compontent to component

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, it worked. I feel so stupid that I didn't see this.

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.