Vue element fails to appear on the screen

As a newcomer to Vue.js and web development in general, I decided to dive into the vuejs guide.

Something puzzled me - when creating a vue component using

Vue.component(NameOfComponent, {...})
and inserting it into my HTML as
<NameOfComponent></NameofComponent>
, the component failed to display.

Let's take an example. The initial argument of Vue.component is TodoItem, which signifies the name of the component. Despite trying

<TodoItem></TodoItem>
, it didn't work and threw an error: [Vue warn]: Unknown custom element: <todoitem> - did you register the component correctly? For recursive components, make sure to provide the "name" option. But oddly enough,
<todo-item></todo-item>
or even
<todo-Item></todo-Item>
worked perfectly fine.

What naming convention should I adhere to in order to resolve this issue? Your insights are greatly appreciated!

Vue.component('TodoItem', {
  template: '<li>This is a todo</li>'
})

const app = new Vue({
  el: '#app',
})
<!DOCTYPE html>
<html>
<head>
  <meta charset='utf-8'>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cd87848eab979b93968d80909497bd">[email protected]</a>/dist/vue.js"></script>
  <title>Vue docs</title>
</head>
<body>
  <div id='app'>
    <ol>
      <TodoItem></TodoItem>
    </ol>
  </div>

  <script src='main.js'></script>
</body>
  
</html>

Answer №1

Give the kebab-case default a try to see the component

Vue.component('TodoItem', {
  template: '<li>This is a todo</li>'
})

const app = new Vue({
  el: '#app',
})
<!DOCTYPE html>
<html>
<head>
  <meta charset='utf-8'>
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1b6d6e7e5b29352d352a2f">[email protected]</a>/dist/vue.js"></script>
  <title>Vue docs</title>
</head>
<body>
  <div id='app'>
    <ol>
      <todo-item></todo-item>         // comment - Line changed
    </ol>
  </div>

  <script src='main.js'></script>
</body>
  
</html>

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

From transforming nested JSON into flat JSON structures within Javascript

Currently, I am faced with a challenge in my JavaScript programming. The task at hand is to transform the JSON data obtained from an API into a different structure while maintaining the essence of the original JSON. The existing JSON comprises members, num ...

Automatically collapse the Shadcn-UI Accordion when the mouse exits

For my self-education project, I am working on building a sidebar with an accordion using Shadcn-ui, NextJS (13.4), React, and Node. Being new to these technologies, I have encountered a problem that I can't seem to solve. The sidebar expands on mous ...

At what point are DOMs erased from memory?

Recently, I've been working on an application that involves continuous creation and removal of DOM elements. One thing I noticed is that the process memory for the browser tab keeps increasing even though the javascript heap memory remains steady. To ...

Refreshing the Angular resource under observation

My brain feels a bit fried today, so pardon what might seem like an obvious question. I have a useful resource at my disposal: Book = $resource("/books/:id", {id: "@id"}); book = Book.get(1); When I want to refresh the object to receive any updates from ...

Learn how to integrate Bootstrap with Vue.js TreeView in this tutorial

If you're looking to create a treeview using Vue.js, the code structure would resemble something like this: HTML: <!-- item template --> <script type="text/x-template" id="item-template"> <li> <div ...

What is the best approach to retain a user's selection for dark mode?

I have created a small website to showcase my work, but I'm struggling to figure out how to make the website remember a user's choice of dark mode. After searching on Stack Overflow, I came across suggestions like using cookies or localStorage. ...

Create custom error messages for loopback instead of using the default ones

I am attempting to customize the default error messages provided by loopback. Here is my approach: server/middleware.json: { "initial:before": { "loopback#favicon": {} }, "initial": { "compression": {}, "cors": { "params": { ...

Unstyled Cards Failing to Receive Design

I am currently working on creating a prototype that utilizes two Bootstrap 4 cards to display information from a form and store related information from another form in the second card. The current layout of this setup can be observed below: https://i.sst ...

Ways to output a string array from a JSON object containing additional attributes

On the client side, I have received a JSON object from a REST service. This object contains multiple attributes, one of which is a String array. I need guidance on how to display this array using embedded AngularJS code in HTML. Here is my JSON object: [ ...

Execute identical task using a for loop in JavaScript

Here is a sample code snippet: var seats = [] for (a = 0; a <= seatsNumFront; a++) { seats.push(new Seat((a * xPad) + 300, 60, 30, 30, id++, "A", a, "#998515")) } for (b = 0; b <= seatsNumFront; b++) { seats.push(new Se ...

Change the size of the font with a slider in VueJS

I have been utilizing the project found at This particular project allows end-users to reuse Vue components as editable sections by providing a styler overlay for adjusting content within a div or section. After installation, I added a slider which now ap ...

How to avoid property sharing in Angular recursive components

I am currently working on a recursive component that generates a tree structure with collapsible functionality. However, I am facing an issue where the state variable active is being shared among child components. Is there a way to prevent this from happen ...

Improving the readability of Vue production files through editing

In order to increase efficiency, I am looking for a way to edit Vue build files directly in production. Making modifications on the fly is much quicker than locating the correct version of production code, making changes, rebuilding it, and then deploying. ...

Is it acceptable to copy and paste the Package-Lock.json file from 19 hours ago in order to resolve the "ValidationError: Progress Plugin Invalid Options" issue in Vue 3?

My Vue 3 project was running smoothly, and I pushed the latest version to GitHub about 19 hours ago. However, when I tried running npm run serve 5 hours later, an error occurred with the following information: > <a href="/cdn-cgi/l/email-protection" ...

Steps for updating the property "project_id" within a nested JSON array to "project_name"

Issue: [ { "project_id": 1, "project_name": "CDP", "role": "PL" }, { "project_id": 2, "project_name": "Admincer", "role": "PM" }, I am trying to extract the "project_id" property from the above JSON array and add it to another array using a specific ...

JavaScript: A guide on sending an uploaded email to a web service in byte array format

Scenario: My website is built using EXTJS6. I have a web service that requires the uploaded email to be sent in byte array format. Inquiry: What is the process for converting a .msg file to a byte array using JS (or EXTJS)? Can we treat it as a simple bin ...

Is there a way to emphasize text within a string of object array items?

I am currently utilizing the data provided below to pass as props in React. The functionality is working smoothly, but I have a specific requirement to only emphasize the words "target audience" within the text property. Is there a feasible way to achieve ...

Execute Function after Gridview Sorting

While working on a gridview within an update panel, I encountered a scenario where the gridview successfully resorts itself upon clicking on the column header. However, post-sorting, I wish to execute a JavaScript function named MyScript. Any suggestions ...

Determine if every object in the array contains a specific key value pair

I am dealing with the following JSON data: { records:{ data:{ current:{ records:{ '2years':[{a:1, b:2, flag:true}, {a:2, b:4}, ...

Is it possible to utilize EmberJS or other frameworks without the necessity of setting up its server?

I am in search of a JavaScript framework that offers the following features: MV* Well-structured HTML file as template Fast rendering (possibly using virtual DOM) Ability to combine and be compatible with other plugins or libraries Edit on tablet IDE app ...