首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我在使用vue路由器vue 2.0时遇到此错误

我在使用vue路由器vue 2.0时遇到此错误
EN

Stack Overflow用户
提问于 2020-06-23 07:21:55
回答 1查看 32关注 0票数 0

我得到了这个错误:[Vue warn]: Unknown custom element: <router-view> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

我确保Vue路由器已正确安装。

routes.js

代码语言:javascript
复制
import Login from './views/Login.vue';
import Home from './views/Home.vue';
import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

export default new Router({
    routes:[
        {
            path:'/',
            name:'home',
            component:Home
        },
        {
            path:'/login',
            name:'Login',
            component:Login
        }
    ]
});

App.vue

代码语言:javascript
复制
<template>
  <div id="app">
    <img alt="Vue logo" src="./assets/logo.png">
    <router-view/>
  </div>
</template>

<script>


export default {
  name: 'App',
 
}
</script>

<style >

</style>

Login.vue

代码语言:javascript
复制
<template>
   <div class='login'>
    <h3>Sign in</h3> 
    <input type="text" placeholder="Email"><br>
    <input type="password" placeholder="Password"><br> 
    <button>Connection</button>
   <p>You don't have an account? Sign up</p>
  </div>
</template>

<script>
export default {
  name: 'login',
  data(){
      return {};
  },
  methods:{}
}
</script>

<style scoped>
.login{
  margin-top:40px;
}
input{
 margin:10px 0;  
}
button{
  margin-top:20px;
  width:10%;
  cursor:pointer;
}
p{
  margin-top:40px;
  font-size: 13px;
}
p a {
  text-decoration:underline;
  cursor: pointer;

}
</style>
EN

回答 1

Stack Overflow用户

发布于 2020-06-23 07:27:36

是否确实要使用名为Home而不是App的组件?您显示了App组件的代码,但没有显示Home的代码,所以我不知道问题出在哪里

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62524975

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档