我创建了我的第一个Vue应用程序,我遇到了路由器的问题。我有3个组件,前2个完美,但3个没有。这是我的代码:
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>
我不知道自己做错了什么。我尝试在登录路由中使用Register.vue并且它有效。我做错了什么?在此先感谢您的帮助!
如果重要,我按npm run dev
运行服务器。
答案 0 :(得分:3)
将属性compontent
重命名为component