Have you properly registered the component? When using recursive components, be sure to include the "name" option. This can be found in the <Root> section. VUE

While diving into Vue with Vuex, I attempted to create a component but encountered this frustrating error:

vue.js:634 [Vue warn]: Unknown custom element: actividadescomponent - did you register the component correctly? For recursive components, make sure to provide the "name" option. (found in )

error screen shot

I experimented with various approaches but unfortunately couldn't crack the solution.

This is the snippet of HTML code that's causing trouble:

    <!DOCTYPE html>
<html>
<head>
    <title>Vue</title>
    <!-- Vue -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <!-- Vuex -->
    <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="740201110c34475a425a">[email protected]</a>/dist/vuex.js"></script>
</head>
<body>

    <div id="caja-vue">
        <actividadesComponent></actividadesComponent>
    </div>
    


    <script src="codigo.js"></script>   
</body>
</html>

Below is the corresponding JavaScript code:

//components
Vue.component('actividadesComponent', {
    template: /*html*/
        `   <div>
                <h1>Hola mundo</h1> 
            </div>
        `,
    computed: {
        ...Vuex.mapState(['actividades'])
    },
    methods: {
        ...Vuex.mapActions(['llamarJson'])
    }
});

//Vuex
const store = new Vuex.Store({
    state: {
        actividades: [],
        programas: []
    },
    mutations: {
        llamarJsonMutation(state, llamarJsonAction){
            state.actividades = llamarJsonAction;       
        }
    },
    actions: {
        llamarJson: async function(){
            const data = await fetch('/Documentos/Calendario-academico/calendario-2021-prueba.json');
            const actividades = await data.json();
            commit('llamarJsonMutation', actividades);
        }
    }
});

//Vue instance
new Vue({
    el: '#caja-vue',
    store: store
});

Answer №1

In the world of In-DOM templates, tag names undergo a transformation to lowercase, resulting in:

<customcomponent></customcomponent>

Consider these two alternatives:

  1. Embrace kebab case within the DOM structure:

    <custom-component></custom-component>
    

    This approach is effective as Vue will seamlessly recognize and register the component even with different capitalization.

  2. Alternatively, you can register the component using an all-lowercase naming convention:

    Vue.component('customcomponent', ...)
    

Refer to the Component Registration section in the documentation for further insights.

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

Troubleshooting the 'ReferenceError: requestAnimationFrame is not defined' error in Vuetify unit testing

Running vue run test:unit with certain Vuetify components is resulting in the error outlined below: ReferenceError: requestAnimationFrame is not defined at VueComponent.mounted (dist/js/webpack:/src/components/VTextField/VTextField.ts:229:1) a ...

SignalR 2.2 application encountering communication issues with client message reception

I am facing an issue in my application where clients are not receiving messages from the Hub when a user signs in. Here is my Hub class: public class GameHub : Hub { public async Task UserLoggedIn(string userName) { aw ...

React functional components with checkboxes can trigger rerenders

I'm currently working with Gatsby and have a functional component that iterates through a set of data to generate a radio button group with an onchange event and a checked item. Whenever I update the state, the entire page component re-renders. I thou ...

How can I add the v-cupertino module to my Nuxt.js project?

Recently, I stumbled upon an intriguing Vue.js module named v-cupertino. However, I couldn't find any guidance on how to integrate it with Nuxt.js. I attempted the following steps: import Vue from 'vue'; import VCupertino from "v-cuper ...

Retrieve populated information from Mongoose and send it to the client

While working on the server, I successfully populated user-data and printed it to the console without any issues. However, I am facing a challenge in accessing the data on the client side or even through the Playground of GraphQL. Below is my Schema setup ...

Angular utilizes ZoneAwarePromise rather than a plain String output

I expected the giver code to return a string, but it is returning ZoneAwarePromise. Within the service: getCoveredPeriod() { let loanDetails = this.getLoanDetails().toPromise(); loanDetails.then((res: any) => { const coveredPeriodStart ...

Only display entries with no content

When attempting to filter data from a search, all results are being displayed on the submit button even when entering 1, 2, or 3. Here is my code below. Please let me know if I am making a mistake somewhere. ...

Is there a way to specify the dimensions of the canvas in my image editing software based on the user-input

Here is the code and link for my unique image editor. I would like to allow users to enter the desired width and height of the selection area. For example, if a user enters a width of 300 and height of 200, the selection size will adjust accordingly. Addit ...

Incomplete Loading of Google Maps

Let me clarify that the solutions I have come across so far have not been successful. I am attempting to display a modal alert with a basic Google Maps integration. Problem: Google Maps does not load completely. Snippet from my .js file: var map; functi ...

Troubleshooting issue with jquery.i18n.properties functionality

I am encountering an issue with implementing jQuery internationalization. I have included the files jquery.i18n.properties.js, jquery.i18n.properties-min.js, and jquery-min.js in my resources folder. In my jsp, I have added the following code: <script ...

The mousedown event does not seem to function properly on dynamically added text elements

When two texts are enclosed in p tags, my goal is to create an interactive function where clicking on one text causes it to move slightly and the other text to be temporarily deleted. However, when the deleted text is re-added after clicking on the first t ...

Creating a file object in NodeJS with a specific file path - a step-by-step guide

Is there a way to create a File object in NodeJS using the path of an existing file, similar to how it can be done on the client side? In other words, is there an equivalent function in NodeJS to achieve the following: function srcToFile(src, fileName, mi ...

Using Node.js, we can create a program that makes repetitive calls to the same API in a

My task involves making recursive API calls using request promise. After receiving the results from the API, I need to write them into an excel file. Below is a sample response from the API: { "totalRecords": 9524, "size": 20, "currentPage": 1, "totalPage ...

Guide to implementing the onchange event in JavaScript for this specific scenario

How can the onchange event be utilized in this scenario using JavaScript? First, input data into the input with id="one". Subsequently, the data in the input with id="two" will be updated to match the data in the input with id="one". However, when the da ...

The functionality of ng-click and ng-repeat in AngularJS seems to be dysfunctional

I have knowledge about the different scopes within ng-repeat, I've heard about it but still can't figure out how to remove a selected item from the list without using $index and affecting future sortable objects. <li class="m-1" ng-repeat="st ...

What is the process of submitting a webhook request using a Google Docs extension?

Is it possible to develop a Google Docs add-on that can send an AJAX call to a webhook? I attempted the following code, but encountered an error. Error ReferenceError: "$" is not defined. (line 5, file "") Code function myFunction() { var arr = &ap ...

Display four unique automobile insignias using Webcomponent/Stencil.js

Exploring Web Components and Stencil.js for the first time, I'm currently developing an application that offers detailed car information based on the user's selection of car type. The challenge I'm facing involves displaying four different l ...

Learn how to create an animated refreshing icon in React when clicked

I have a refresh icon in my React app that utilizes Material UI. I want the icon to spin for a second after it is clicked, but I am unsure of how to achieve this. Despite attempting some solutions, none have been successful. const useStyles = makeStyles(( ...

What is the best way to transfer nested function parameters to the main function parameters?

I have a function that creates animations on DOM elements using the animate.css library as the user scrolls to specific coordinates on the page. The functionality is working perfectly. $(window).scroll(function() { $('.dev-courses__item').ea ...

What is the best way to toggle a sticky footer menu visibility using div elements with JavaScript instead of relying on pixel measurements?

Just wanted to mention that I'm pretty new to this, so if I use the wrong terms, I apologize in advance. I am trying to replicate Morning Brew's sticky footer opt-in form (check it out here). However, the code I have now only tracks pixels. Is t ...