Encountered a problem resolving the asynchronous component rendering with View-Router

While attempting to integrate VueJs with VueRouter, I encountered a problem. The Home component is displaying the log message but not the template section. Additionally, an error was thrown as shown below:

https://i.sstatic.net/2YWQL.png

Home.vue

<template>
    <div class="wrap" id="app">
        <h1 class="inline">Hello There</h1>
    </div>
</template>

<script>
export default {
    name: 'app',
    data () {
        return {
            maps: []
        }
    },
    mounted() {
        console.log( 'Mounted Homepage' );
    }
}
</script>

<style lang="scss">
#app {
   font-family: 'Avenir', Helvetica, Arial, sans-serif;
   -webkit-font-smoothing: antialiased;
   -moz-osx-font-smoothing: grayscale;
}
</style>

routes.js

import Vue from 'vue';
import Home from './components/Home.vue';
import NotFound from './components/NotFound.vue';

const routes = [
    { name: 'home', path: '/', components: Home },
    { path: '*', component: NotFound, meta: { title: 'Not Found' } }
];

import VueRouter from 'vue-router';
Vue.use(VueRouter);


var router = new VueRouter({
    routes
})

export default router;

Main.js

import Vue from 'vue'
import NotFound from './components/NotFound.vue'
import router from './routes'

new Vue({
    router,
    components: {
        NotFound
    }
}).$mount('#rgm_app');

It seems there may be something that I overlooked. Can you help identify what it might be?

Answer №1

There is a small mistake in this array declaration:

const routes = [
    { name: 'home', path: '/', component: Home },
    { path: '*', component: NotFound, meta: { title: 'Not Found' } }
];

All you need to do is remove the extra s from component in the first object, and everything should work fine.

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

Transfer various field values to jQuery

I am looking to send multiple field values to jQuery for validation, but currently only receiving the value of the changed field. How can I pass both field values to jQuery? Enter some text: <input type="text" name="txt1" value="Hello" onchange="myF ...

Bring back hover guidelines following mouse click

I have implemented a script to toggle the visibility of my main navigation menu items. Check out the live demo here: ! There is a specific section of my menu that includes downward arrows (displayed using font awesome icons within <i> tags), which s ...

Programming the action of unfolding one window while simultaneously closing all others

I am facing an issue where the foldout function is working perfectly, but I need the second function to run first in order to close all other elements. Unfortunately, I can't seem to figure out what the problem is. Any help would be greatly appreciate ...

Integrating XML API Requests Using HTML and JavaScript

When there is only one item in the XML document, I want to update my inner HTML with the result of an API call. I have managed to successfully make the API call work when there are multiple items in the XML document (thanks to W3). <!DOCTYPE html> ...

Tips for integrating both client-side and server-side validation techniques in your web application

After conducting some research, I have come across information indicating that it is feasible to implement both client-side and server-side validation simultaneously. However, my focus is not solely on learning JavaScript; I am also interested in utilizi ...

Steps for retrieving the URL using the getDownloadURL() method

After exploring various options, I have come across multiple solutions but none seem to be suitable for my specific requirements! I have managed to successfully upload a photo to Firebase along with all necessary information. However, when attempting to r ...

What is the proper way to incorporate quotation marks within other quotation marks?

Is there a way to generate an ID within the myFunction() function in JavaScript? I need a single string to call an HTML script as a variable. Any corrections or suggestions are welcome. Here is a sample code snippet: <button class="tablinks" onclick=" ...

What is the method for assigning a value to a variable in xhr.setRequestHeader?

I'm working on setting a value to the variable in xhr.setRequestHeader(Authentication, "Bearer" + parameter); with xmlhttprequest. Can you provide guidance on how to effectively pass a value to the variable within xhr.setRequestHeader? ...

Node.js application experienced a crash following an incorrect login credential attempt

In my login code, everything works fine when the user enters the correct credentials. However, if the wrong credentials are entered, an error message saying "Internal server error" is displayed and the app crashes. This happens because I have written a c ...

Unable to implement the checkCollision function within the Snake game using JavaScript

My latest project involves creating a Snake game using canvas in JavaScript. I've managed to set up most of the game, but I'm having trouble with the collision check. Whenever the snake hits itself or the wall, the game crashes because I can&apos ...

Challenge with executing javascript library (photo sphere viewer)

I was excited to incorporate Photo Sphere Viewer into my project. After running npm i photo-sphere-viewer I noticed that the modules were successfully downloaded. Following that, I added this line inside my project: import PhotoSphereViewer from ' ...

The response from AJAX is successfully retrieved, however, the HTML code within the response is not being appended to the

html: <form method="POST"> <input type="text" name="input1" id="input1"> <input type="text" name="input2" id="input2"> <button type="button" onclick="checkInputs()">OK</button> </form> <div id="display_panels">< ...

Looking for a way to identify when a DOM element is resized as a result of web fonts loading asynchronously?

Within this div element lies text styled with a custom font via CSS's @font-face attribute. The issue arises when the font hasn't loaded yet, causing a delay in updating the font style of the text within the div. As a result, taking measurements ...

Determine whether an element is absent from an array before displaying a window

Currently, I am working on developing a chat interface where you can interact with your online and offline contacts. One of my challenges is creating a function to prevent duplicate chat windows from opening. You can take a look at what I have accomplished ...

In three.js, a full rotation on the Y axis is not achievable for cubes

My low poly world features gravity added with raycasting to the character. Now, I am looking to incorporate another raycaster in front of the character, specifically the pointer lock controls, to enable walking on non-flat surfaces. This raycaster would al ...

The Storybook compilation consistently encounters errors

Check out my repository here: https://github.com/zapify-ui/zapify I'm facing an issue with building Storybook using the command: npm run build-storybook How can I identify the specific error or debug it effectively? The error thrown is: (node:46619) ...

Rendering Objects with Three.JS in an AngularJS Directive

I am currently in the process of integrating Three.JS into an AngularJS directive. Right now, my main goal is to create a proof-of-concept implementation that can serve as a template for a more complex directive in the future. Currently, I am utilizing th ...

Is it possible to merge a string with a variable using v-model?

After exploring various solutions for a similar issue like this, I am still unable to make my template compile successfully. The challenge lies in concatenating a string with a variable within v-model to bind to an array inside an object: <li v-for=&qu ...

What function does listener() serve within the Redux store?

I'm currently studying Dan Abramov's Redux tutorials on Egghead. At the part where he constructs the Redux Store from scratch, there is this code snippet (around 1:28 - ): const dispatch = (action) => { state = reducer(state, action); lis ...

Enhance the display using ngOnChanges when receiving input in Angular

My child component has an @Input property of type Person where the object is passed from the parent component through an attribute. You can find the complete working code on StackBlitz After researching a similar question and following the provided answe ...