Having an issue with Vue Router in Vue 2.0, encountering an error

I encountered the following error message:

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

I double-checked that the Vue router is installed correctly.

routes.js

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

<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

<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>

Answer №1

Could it be possible that you have mistakenly used the component named Home instead of App? You've provided the code for the App component but not for Home, making it difficult to identify the issue.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue arising from the lack of direct communication between parent and child elements

I am facing an issue with indirect communication in a react native application. The situation involves a parent component, implemented as a class component, and a child component, which is a functional component. Here is the Parent component: constructor ...

Gather data from various HTML elements with JavaScript when submitting a form

How can I extract values from HTML elements and send them for processing through a form? I'm attempting to compile a menu item list with the individual items' structure in place, but I'm struggling to figure out how to fetch the values upon ...

Update the ngModel value once input validation has been successfully validated

My input is defined as shown below <input id="xInputControl" name="xInputControl" type="text" xInput class="form-control" [(ngModel)]="x" #validated="ng ...

Vue 2.0: Exploring the Power of Directive Parameter Attributes

It has come to my attention that directive param attributes have been phased out in Vue.js 2.0. As a result, I am unable to use syntax like v-model="msg" number within an input tag. Are there alternative methods to achieve the same outcomes without relyi ...

The combination of Javascript and CSS allows for interactive and visually

I'm currently working on a project where I had to create a simulated weather page using only Javascript. However, I am struggling with the overall layout and have a few questions that I hope someone can help me with: Despite trying various methods ...

Compatibility Issue between Jquery UI CheckBox Button and Click Function in IE8

Situation: After calling addButton() function in jQuery, the checkbox element is successfully turning into a button. However, the click event that should trigger an alert message is not functioning. This issue seems to be specific to IE-8 compatibility. ...

Ways to customize the appearance of an iframe's content from a separate domain

I am facing a challenge with my widget and multiple websites. The widget is hosted on one domain, but the websites use an iframe to display it. Unfortunately, because of the Same Origin Policy, I cannot style the content of the iframe from the parent websi ...

The perfect method for creating template literals using a function

I have a function that accepts an argument called id and returns a template literal: const generateTemplate = (id) => { return `<div style="box-sizing: border-box; height: 32px; border-bottom: 1px solid #ECECEC; color: #282828; padding: 8px; dis ...

Tips for getting the Storybook addon 'addon-links' up and running smoothly with Vue.js?

I'm currently in the process of learning how to utilize Storybook for a project that involves Vue.js. I've encountered an issue with getting the 'addon-links' to function properly, as most of the documentation is geared towards React. ...

Would you like to learn how to extract data from a specific textbox using jQuery and save it to a variable when the textbox is in

Below is a textbox that I am working on: <input type="text" name="company" id="company" required /> I am trying to figure out how to use jQuery to capture the values inside the textbox whenever they are typed or selected. Despite my efforts, I hav ...

Unique Version: When utilizing custom window.FileReader methods, Angular zone execution is bypass

Upon transitioning an Ionic/Angular project from Cordova to Capacitor, I found it necessary to override the default window.FileReader in order to successfully execute the onload() method. Here is the approach I took (https://github.com/ionic-team/capacitor ...

AngularJS promise fails to resolve when attempting to read a file using the FileReader

Can someone assist me with a function I am trying to create in my service? I want the function to use FileReader to read a small image file and return the result in a promise to my controller. The issue is that while the file reaches the service without an ...

What is the best way to personalize the collector for each individual?

Currently, I have a bot that is capable of collecting messages and replying if it detects a specific word. However, I am facing an issue where the bot keeps creating new collectors every time someone types the word tekong. As a result, the bot ends up resp ...

When combining Socket.io 1.0 with express 4.2, the outcome is a lack of socket connection

According to the title, I am attempting to integrate socket.io 1.0.4 with express 4.2, but all requests with "/?EIO" are resulting in a 404 error. Below are my file configurations: ./bin/www : #!/usr/bin/env node var debug = require('debug')(& ...

Establish an interval that loops through the elements of an array

I'm currently working on implementing an interval for the length of an array stored in state. The particular array eventDate consists of 4 elements, and I want the function to cycle through values 0, 1, 2, 3, then loop back to 0. This is my code ...

The OOP functionality in Three.JS seems to be malfunctioning, as certain elements are not being properly accessed and displayed

I've run into some issues while trying to implement OOP in my Three.js project. The original script displays three y-rotational planes, but it seems like some objects I've created aren't being called when I check the console. Can someone ple ...

Is there a way to differentiate between a browser application running on a local development server and an online staging server?

Is there a way to conditionally call a component only on the staging server and not on the local machine in Vue.js? <save-drafts-timer v-if="!environment === 'development'" /> ... data () { return { environment ...

Ways to change a value in an array within MongoDb

My array value is being overridden by $set, how can I update it properly? var obj = // contains some other data to update as well obj.images=images; // updating obj with images [] Units.update({_id: 'id', {$set: obj}); Ultimately, my MongoDB ...

Unable to update the contents within a div when clicking on a link

I have a container with a link and some text inside. When the link is clicked, I want to change both the link itself and the content within the container. There are two different links: <a href="#" class="add1> Add </a> <a href="#" class=" ...

Ways to obtain a referrer URL in Angular 4

Seeking a way to obtain the referrer URL in Angular 4. For instance, if my Angular website is example.com and it is visited from another PHP page like domaintwo.com/checkout.php, how can I detect the referring URL (domaintwo.com/checkout.php) on my Angul ...