Using Vue to pass the outcome of a function for date parsing

Is there a way in VUE to pass the result of currentView.lastSuccessRunDate, perform some operations on it, and display the modified output in a table instead of directly using the API response? I'm looking for a function that can take this response as a parameter and return an edited output.

 <tr
      class="bg-gray-100 border-b border-gray-200"
      v-for="currentView in getDashboard()"
      :key="currentView.id"
    >

   <td class="px-4 py-3">N/A</td>
    <td class="px-4 py-3">{{currentView.name}}</td>
     <td class="px-4 py-3">{{currentView.lastSuccessRunDate}} </td>
     <td class="px-4 py-3">{{currentView.lastFailedRunDate}}</td>
  <td class="px-4 py-3">{{currentView.lastRunDuration}}</td>
    </tr>

Solution(As obvious as it may seem):-

{{ calculateDateIntervels(currentView.lastSuccessRunDate) }}

I also used the moment library, which was very effective.

Answer №1

Perhaps consider utilizing a filter for this scenario

Vue.filter('capitalize', function (value) {
  if (!value) return ''
  value = value.toString()
  return value.charAt(0).toUpperCase() + value.slice(1)
})

<td class="px-4 py-3">{{currentView.lastSuccessRunDate | capitalize }} </td>

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

Looping through an array of nested objects using Vue

I have encountered a challenge with accessing specific data within an array that I am iterating over. The array is structured as follows, using Vue.js: companies: [ name: "company1" id: 1 type: "finance" additionalData: "{& ...

Tips for efficiently querying an array of objects with dynamic search criteria in VueJs3?

I have a search feature that scans through Objects and displays results based on the chosen search parameter (ID, NAME). While searching by ID works perfectly, trying to search by name returns undefined. I'm puzzled as to why ID can be successfully s ...

Creating a variable by utilizing $index values within two nested v-for loops

For my project, I am attempting to organize the days of a month into a table using 2 v-for loops. To simplify my code, I am considering creating a t_index variable that would be equal to ((r_index - 1) * 7 + c_index) - 2, but I am unsure how to implement ...

The v-show directive is not activated by a Vuex commit

I am experimenting with vuex for the first time, and I have come across an issue where a v-show directive is not triggering after a mutation commit on the store. // store.js import Vue from "vue" import Vuex from "vuex" const states = ...

What is the process for integrating a component into this Vue component?

If we are looking to incorporate a component from into the following code snippet, things get a bit tricky. The provided example is not tailored for decorator definitions. So, where exactly should the component list be placed within this script? <sc ...

Creating powerful Vue event handlers with composable functions

I am currently working with Vue 2.0, ES6, and Webpack. In my project, I have a Parent component and several child components called text-input. Each text-input emits a change event that should modify a different property inside the Parent component. For i ...

Creating a file structure for JavaScript files in a Vue CLI project

When structuring my Vue CLI project, I'm struggling to find clear documentation on best practices. Currently, I have 10 modules each with an associated JS file. My approach so far involves organizing all the pages in my router.js within a views direc ...

Ways to halt code execution if the component is not actively in use in Nativescript Vue

I'm facing an issue with my application where it continues to send data about the device every 5 seconds even when I minimize the app and reopen it or navigate away from the page. This leads to a situation where the function of sending data is trigger ...

Make sure to prevent losing the global status in Vuex and VueRouter when the page is refreshed

As I develop a Single Page Application (SPA), I am utilizing Vuex to manage session states on the client side. However, I have noticed that the state resets whenever the browser is manually refreshed. Is there a way to prevent this behavior without relying ...

How can I prevent pre-defined array items from being replaced by database values?

Incorporating Vue Select into my project to create a tag list for users to add and save to a database has been successful. However, I'm facing an issue where I want to include some predefined tags in the list for users to select from. When attempting ...

Create a data attribute object and assign to it the prop object received from the parent component

I am struggling with passing an object as a prop from a parent component and then utilizing it to initialize the child component with the received value. The main objective behind this is to create a dialog box that includes a child form component with mu ...

VueJS: using dynamic class names within the style attribute

Within my VueJS application, I have implemented Materializecss modals within single page components. Each modal requires a unique dynamic ID due to the application's requirements. The code snippet below showcases this: <template> <div :i ...

My experience with the Vue.js program has been disappointing as it is failing

Below is an example of my Vue.js code: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport&quo ...

Switch language by entering a specific URL (VueJs)

I have successfully integrated localisation using vue-i18n. In my main.js file: import Vue from 'vue' import { i18n } from './plugins/i18n' import Cookie from "vue-cookie"; if (!Cookie.get('locale')) { Cookie.set(' ...

What is the best way to incorporate this into a Vue project?

I am in the process of transitioning my code to Vue.js, so I am relatively new to Vue. In the screenshot provided (linked below), you can see that there are 4 columns inside a div with the class name columns. I attempted to use the index, like v-if='i ...

Vuex - Issue with module state causing undefined return value

Hey there, I'm a bit puzzled as to why the state property is returning undefined. I am relatively new to vue.js and really need to grasp how this all functions. Here's what I've been working on: In my state.js file for let's say the t ...

"Troubleshooting: NuxtJs vue-flip feature stuck on front side, not rotating to

I have recently installed the vue-flip plugin in a NuxtJs (VueJS) project that I created using the command: npx create-nuxt-app <project-name>. In the index.vue file, I simply added: <vue-flip active-click="true"> <div slot="front"> ...

Interpret vBulletin's BB Code using PHP

I need a custom function that can convert BB Code from vBulletin to standard HTML formatting. I want to avoid using the PEAR library or PECL extension in order to eliminate any dependencies. It would be acceptable if I could get access to the source code ...

Is there a way to access data dynamically during rendering and display the outcome?

Upon rendering the object below, I am able to implement something similar to: <div v-for="(card, groupIndex) in cards" v-bind:key="card.id"> <div> {{cards[groupIndex].group.length}} </div> </div> This code snippet provides a cou ...

How can you preselect an item in Vuetify's item group?

When attempting to preselect an item from a vuetify item-group, I discovered that it works with strings but not with objects. The vuetify documentation shows using a string array as the item list for the item-group, which functions correctly. However, whe ...