Tips for utilizing v-for on data attribute in vue and ionic?

I have been attempting to implement a v-for loop on the data() property in Vue.js + Ionic, but it doesn't seem to be working as expected. When I try to check the property using console.log(this.workOrders)

The output I get looks like this:

[[Handler]]: Object
deleteProperty: ƒ deleteProperty(target, key)
get: ƒ (target, key, receiver)
has: ƒ has(target, key)
ownKeys: ƒ ownKeys(target)
set: ƒ (target, key, value, receiver)
__proto__: Object
[[Target]]: Array(2)
0: {id: 8, internal_control_number: "1234567", date_of_work: "02/24/2021", agent: "6", ranch: "2", …}
1: {id: 3, internal_control_number: "12345678765432", date_of_work: "2021-02-24", agent: "6", ranch: "1", …}
length: 2
__proto__: Array(0)
[[IsRevoked]]: fals

Axios is providing a response and the data is coming through, but it only appears under [[Target]] index. This behavior is puzzling to me - can anyone shed some light on why this might be happening? Any guidance would be greatly appreciated.

Below is the code snippet I'm working with:

<template>
<ion-header>
      <ion-toolbar>
        <ion-title>Notifications</ion-title>
         <ion-buttons slot="start">
          <ion-menu-button auto-hide="false"></ion-menu-button>
        </ion-buttons>
        <ion-buttons slot="primary">
          <ion-button color="secondary" @click="handleSignOut">
            <ion-icon slot="icon-only" :icon="logOut"></ion-icon>
          </ion-button>
        </ion-buttons>
         <ion-buttons slot="primary">
         
        </ion-buttons>
      </ion-toolbar>
    </ion-header>
  <!-- List of Text Items -->
  <ion-list >
    <ion-item :v-for="(work_order,index) in this.work_orders" 
               :key="index">
      <ion-label >{{ work_order }}</ion-label>
    </ion-item>
   
  </ion-list>
<side-menu/>
</template>

<script>
import { 
  IonItem, 
  IonList, 
  IonLabel, 

} from '@ionic/vue';
import { defineComponent } from 'vue';
import SideMenu from '../SideMenu.vue';
import ApiService from "../../services/api.service";
import { TokenService } from "@/services/token.service";

export default defineComponent({
  components: { 
    IonItem, 
    IonList, 
    IonLabel,
    SideMenu,
    
  },
  data(){
    return {
    work_orders : [],
    }  
  },
  methods:{
   getWorkOrders : function()
   { 
  
     const boss_id = TokenService.getUserInfo().role_details.id;

    return  ApiService.get(`/api/gangBoss/workOrders/view/${boss_id}`)
                    .then((response) => {
   
                        this.work_orders = response.data;
                        console.log(this.work_orders);
                    });
   }
  },
  mounted(){
    this.getWorkOrders();
  }

});
</script>

Answer №1

It seems like a mistake to have binding syntax within the v-for attribute of your ion-item element:

<ion-item :v-for="(work_order,index) in this.work_orders" :key="index">

Consider removing the unnecessary binding:

<ion-item v-for="(work_order,index) in this.work_orders" :key="index">

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

What are the steps to implement PostgreSQL mod for Vert.x in JavaScript?

Hi there, I'm a newcomer to Vert.x and I am interested in utilizing the https://github.com/vert-x/mod-mysql-postgresql for a particular service. Below is a snippet of code that I am using for my web server: var vertx = require('vertx'); var ...

Arrange the JSONB data type with sequelize literal in your order

My current approach involves querying for all items using the following structure: const filteredItems = await allItems.findAll({ where: conditions, include: associations, order: sortingCriteria, limit: limit, o ...

Guide on passing the set[State] function to a trigger component that is not a descendent

Take a look at this diagram. ChildComponentB contains a state called stateX. In ChildComponentA, when a certain event occurs, it should modify the stateX in ChildComponentB. If ChildComponentA is a child component of ChildComponentB, passing the setStateX ...

Setting the state variable value asynchronously using AngularJS UI-If

Is it possible to limit access to the sidebar until the user has completed the login process? The sidebar is located outside the main ui-view section I am assuming that authenticated is a state variable <div ng-controller="MyController" ui-prevent-to ...

node.js experiencing crashing following loop iteration

I'm currently developing a performance testing tool using node.js to automate the process and store the results in MySQL. This tool is designed to track the load time of specific web pages in a browser, with the measurement displayed in seconds. I am ...

javascript Try again with async await

I am working with multiple asynchronous functions that send requests to a server. If an error occurs, they catch it and retry the function. These functions depend on data from the previous one, so they need to be executed sequentially. The issue I am facin ...

Rendering basic JSON data from the console to an HTML page using Angular

I have been utilizing openhab for sensor monitoring. To extract/inject the items(things), sensor properties, and room configuration through a web interface, I am making use of openhab's REST queries which can be found here - REST Docs. Wanting to cre ...

Button Click Tracking Using Google Analytics for In-Page Searches

Is there a way to track Google Analytics In-Page search using the search code "KEYWORDS site:MYDOMAIN.com" without users immediately jumping to Google upon hitting Enter? I have heard about using Google Analytics hitCallback but I'm not sure how to i ...

An array of tooltips linked to specific areas on an image using

Hello, I have created an imagemap with area polygons that display tooltips when the mouse hovers over them. Additionally, there is a legend at the bottom of the image map. My goal is to show the tooltip on the specific polygon area when the mouse is hove ...

What is the most effective way to assign multiple functions to the onClick event of a button, based on a specific property,

I have a special button that generates a specific type of code when rendered: <button>{this.props.text}</button> This button is named ButtonCustom. In the render method of the main container, I am trying to achieve the following: function my ...

Error in Angular 2: Unable to connect to 'customer' as it is not recognized as a property of 'my-customer'

I have encountered an issue while following an outdated tutorial by John Papa and Buddy Ward. Despite reading various Stack Overflow posts, I still can't resolve the problem. The solution suggested avoiding the use of directives: in my component and i ...

The server returned an undefined status code

Seeking guidance in the right direction would be greatly appreciated. I am currently using Node/Express and consider myself a beginner in this area. Attempting to reuse some code from a previous project that was successful, but have encountered roadblocks. ...

Troubleshooting: Javascript Opacity Slider Malfunctioning on Internet Explorer

I was looking for a way to change the color of an image using a slider. I decided to tweak some Javascript code so that it alters the opacity of a different colored image layered on top of the original one as the slider is adjusted. Additionally, I incorpo ...

Issue with drag-and-drop feature conflicting with clicking in Highcharts draggable points

I'm currently using Highcharts version 3.0.7 along with the draggable-points module to enable users to drag points within a displayed series. Users should have the ability to drag a point to move it, as well as click on a point to remove it. The iss ...

A jQuery collection comprising a variety of elements

Here is the unique markup code: <div id="custom-elements"> <div> <a href="#">unique text 1</a> <a href="#">unique text 2</a> <a href="#">unique text 3</a> ...

Displaying data in a v-for loop without storing the data in an array [vue]

Currently, I am displaying a series of emails using v-for that can be deleted by an administrator. To indicate whether the deletion process is ongoing or not, I need to establish a 'Loading' state that can switch between true and false. While I u ...

Changing the URL within a Vue.js component without navigating away from the component

Just starting out with VueJs and working with wizaplace. I currently have a route set up as /breweries/:id, which uses the company's ID to fetch information from the wizaplace API. Within this data, there is a slug that I would like to display in the ...

Error in Java script C# Web Application when creating a Google Chart due to Index Out of Bounds Array

Hello, I encountered an error in my Java script when trying to run it from the server side. The script includes a for loop that runs over 3000 times and retrieves values from an array with more than 3000 elements. Here is the script: <script type="text ...

The Dropdown Menu is displaying correctly in Chrome, but is being obscured by an image in Safari

While the Nav dropdown menu functions correctly in Chrome, an issue arises in Safari where the image covers the rest of the menu. This discrepancy between browsers is puzzling. Why does this problem only occur in Safari when it displays properly in Chrome? ...

What is the best way to access the front camera on both Android and iOS devices in order to capture a photo using Vue.J

I am currently developing a PWA Vue.Js application and I am trying to implement a feature that allows users to take a picture with the front camera on their mobile devices. Although I have managed to write code that works on my desktop browser, I have bee ...