What could be the reason behind this vuejs v-for loop causing an undefined error?

As a beginner in Vue, I am trying to understand the basics by creating an example that displays a list of numbers which are properties of vue data objects. However, when I attempt to use the v-for directive in a loop, I encounter an error message: TypeError: "fibnum is undefined" I need assistance in identifying and correcting any mistakes in my code or approach.

Here are the relevant files:

index.html

<!doctype html>
<html>
    <head>
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
        <meta content="utf-8" http-equiv="encoding">
        <script src="/vue.js"></script>
    </head>
    <body>
        <div id="fib-triangle">
            <ol>
                <li v-for:"fibnum in fib_row">
                    {{fibnum.num}}
                </li>
            </ol>
        </div>
    </body>
    <script src="./trivue.js"></script>
</html>

trivue.js

(function(){

'use strict'


// Define 'triangle' component to store fib-numbers
var triangle = new Vue({
        el:'#fib-triangle',
        data:{ fib_row:[{num: 1}, {num: 1}, {num: 2}, {num: 3}, {num: 5}, {num: 8}, {num: 10}] }
});


})()

Answer №1

Thus, the correct answer should look something like this:

<html>
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta content="utf-8" http-equiv="encoding">
    <script src="/vue.js"></script>
</head>
<body>
    <div id="fib-triangle">
        <ol>
            <li v-for="fibnum in fib_row">
                {{fibnum.num}}
            </li>
        </ol>
    </div>
</body>
<script src="./trivue.js"></script>
</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

Achieving optimal hardware performance for WebGL compatibility is essential

Lately, I have been exploring the world of Three.js to create impressive 3D scenes in WebGL. To ensure compatibility for all users, I have also developed versions using Three's CanvasRenderer which may not be as detailed but can still function on brow ...

Escaping quotes in JavaScript

After receiving a JSON object in the following format: result: { image: "..." title: "text text \"text\"" } I am currently utilizing underscore.js to render the template, but I am encountering an issue where the title displays with the escape ...

Exploring the capabilities of Redux Toolkit's createEntityAdapter in designing versatile data grids

Seeking guidance on utilizing createEntityAdapter from Redux Toolkit. In my application, I display package information and details using the master/detail feature of the AG Grid library. Packages are loaded initially, followed by fetching detailed data as ...

Is there a way to dynamically insert the user's id into the URL section of an AJAX request?

Seeking to make the '2' in the url field of the getEvents function dynamic by replacing it with the current user's id. I was thinking of using ${current_user.id}. Can someone guide me on how to achieve this? Ideally, I'm aiming for som ...

Issues within jQuery internal workings, implementing improved exception handling for fn.bind/fn.apply on draggable elements

I've been experimenting with wrapping JavaScript try/catch blocks as demonstrated on this link. It functions properly, essentially encapsulating code in a try/catch block to handle errors like so: $.handleErrors(function(e){ console.log("an erro ...

Execute --runTestsByPath on two or more distinct paths

Currently, I am utilizing the jest cli for running my tests. Jest offers a useful cli option known as --runTestsByPath, which allows me to specify the locations of my tests. Despite having unit tests spread out in various directories within my repository, ...

"Learn how to securely redirect to a custom URI scheme with a fail-safe option to display alternative content if not supported

In short: Can a visitor be redirected to a custom URI scheme or shown alternate content if the scheme is not supported? My specific scenario involves developing a mobile app that utilizes a custom URI scheme for users to invite others to actions within th ...

Developing an if-else statement to showcase a different div depending on the URL

Having trouble with an if/else statement to display one div or another based on the URL: No matter what I try, only "Div 1" keeps showing. Here's my code snippet: <script> if (window.location.href.indexOf("pink") > -1) { document.getElemen ...

Incorporate a new CSS class into a DIV using JavaScript

Sample HTML: <div id="bar" class="style_one"></div> Is there a way to include the class style_two without deleting style_one? final outcome: <div id="bar" class="style_one style_two"></div> ...

Each time the page is refreshed, the most recent form data submitted is continually appended to an array

I have implemented a post request to add input data from a form. The entered data is stored in an array variable burg and then displayed on my index.handlebars view. Everything works as intended, but when the page is refreshed without any input in the form ...

Object-oriented programming (OOP) implementation with asynchronous JavaScript and XML (

... I'm currently facing a situation where I have an object: function Page(daoService) { this.daoService = daoService; this.gamesList = this.daoService.getGamesList(); } // Rendering thumbs for main page Page.prototype.renderThumbs = functio ...

Filter an array in Javascript based on multiple conditions

I am working with an array that looks like this: var arr = [ { "id":3, "first_name":"Laila", "last_name":"McCaine", "gender":"female", "populations":[{"population_name":"Heart failure"}, {"population_nam ...

When there is no data in the request body, ExpressJS will display it as empty

A big part of my tech stack includes a website with an express server up and running. The website allows users to insert their username and password. Upon clicking the login button, the server receives a request with the username and password packed as a J ...

Extract information from SQLite in the form of an array, then use Chart.js within an HTML file to create visually appealing charts based on

I am in the process of developing a web app that requires data visualization on a single page. The data for generating visuals is sourced from an SQLite database located locally on my machine. According to the documentation provided by Chart.js, it accepts ...

How can I update an Object's property changes in a Vue DOM element?

I am trying to display the status of an object's property in my DOM element. I have added a property called id to the object and when I use console.log, it shows as true. However, the update is not reflected in the DOM element. How can I make sure tha ...

Using the MySQL WHERE clause in combination with JavaScript to filter data

I could use some assistance. I am transferring text between pages using local storage. How can I condition the variable called "retrievedObject" that holds the text value: var retrievedObject = localStorage.getItem('textValue'); when I want to ...

Having trouble parsing the BODY of a NodeJs JSON post request?

I've been working on creating a basic API using nodeJS, but I've run into a problem while trying to post data. Below is my app.js file: const express = require('express'); const feedRoutes = require('./routes/feed'); const ...

Displaying icon.png in Angular based on item attribute - a step-by-step guide

My data is stored in an array of objects with information about people: [{"name":"Steve", "hourly_wage":16, "status":"part-time"}, {"name":"Maria", "hourly_wage":25, "status":"full-time"}, {"name":"Jose", "hourly_wage":21, "status":"former"}] I am lookin ...

Locate a Checkbox using JQuery and NodeJS

Searching for the presence of a checkbox in a webpage using NodeJS with JQuery (other suggestions are welcome). However, I am struggling to locate the checkboxes within the form. Below is the code snippet from the webpage: <form id="roombookingform" c ...

Would appreciate guidance on incorporating breadcrumbs into the JSP code provided below. Thank you for your help!

I need assistance with implementing breadcrumbs in these hyperlinks to enable tracking. String cat_code= fetch.getCat_code(); %> <% if(P_list!=null && P_list.size()>0) { for(int i=0;i <P_list.size();i++) { b=( Bean)P_list.get(i); % ...