Questions tagged [computed-properties]

Functions declared as properties are known as computed properties. Numerous programming languages offer support for computed properties, thus it is advised to combine this tag with others such as [swift], [javascript], and more.

Retrieve the component instance from a Vue watcher

I'm currently developing a project that acts as a bill manager and I am looking to have the subtotal recalculated automatically whenever the quantity or unit value changes. I've tried using watchers and computed properties to achieve this but haven't found ...

Error in Vue: Expected object but received a function instead of a valid value

I am attempting to apply a computed function to my style. However, the computed function uses a property within it and Vue is throwing an error stating that it expects an object but is receiving a function. Below is the code in question. <template> ...

Set addition fails to trigger computed property

Disclaimer: I'm new to JavaScript I attempted to track all current errors within a component in the following manner, but I seem to be missing something. My error set is updated whenever the username changes, therefore, my computed property displayErrors ...

Challenges with differentiating between addition and concatenation in Vue computed properties

Recently diving into Vue and came across an intriguing issue, I am curious to know the reason behind it and how to prevent it. <template> <div> <input type="number" v-model="a" style="color: white" /> <input type="number" v- ...

Interconnected properties with varying behaviors in Vue versions 1 and 2

Encountering a problem with input boxes having formatted numbers and computed properties when using Vue 2. Whenever an input is changed, Vue automatically recomputes the number, making it difficult to type in exactly what is needed. new Vue({ el: ' ...

VueJS - Best practices for utilizing getters and computed properties efficiently

Vue.js has a special place in my heart, especially its computed properties and the magic of Vuex getters. However, I've reached a crossroads where I'm unsure if my current approach may be impacting performance. This pattern features prominently in my code ...

Why doesn't Vue's computed method call the 'get' function after setting a dependent value in the 'set' function

Allow me to explain how I define a computed value: Template : <date-picker v-model="rangeDate" type="date" format="jYYYY/jMM/jDD" display-format="jYYYY/jMM/jDD" input-c ...

Instead of using a computed getter/setter, make use of mapState and mapMutations to simplify

Currently, I am syncing a computed value to a component and using a computed setter when it syncs back from the component. I'm wondering if there is a more concise way to replace a computed getter/setter with mapState and mapMutations. How can this b ...

Vue dynamic class binding using computed properties

I've been attempting to pass a class from a parent component to a child component using a computed switch case within a slot. Parent: <template> <mcTooltip :elementType="'text'"><p>Test</p></mcTooltip> </templat ...

Updating the CSS class dynamically in Vue using a variable within setInterval

I'm currently diving into Vue JS and I'm looking to dynamically change a class using the setInterval method. However, I'm running into issues passing the changing value of Method to the Computed Property. I want the class to automatically switch after two ...

I'm struggling to figure out the best method for updating data properties in Vue. Computed properties and watchers aren't getting the job done. What

I'm facing a challenge with updating certain input fields on a form I'm currently working on. After receiving data from axios in one data property, I am attempting to prefill some fields with the response. There are four fields returned from the server tha ...

Can a Vue computed property return a promise value?

I have a specific computed property in my code that triggers an API request and retrieves the required data: async ingredients() { const url = "/api/ingredients"; const request = new Request(url, { method: "GET", credentials: "same-or ...

What are some ways to rejuvenate a computed property?

Is there a way to refresh the data displayed in someData after it has been updated and saved on the server? I have tried using $recomputed('someData'), but it's not working as expected. I believe I might need to utilize a Promise, but I'm unsure about how ...

Efficiently transferring a style property to a child component as a computed property in Vue.js

Currently, I am facing an issue that involves too much logic in my inline style, which I would like to move inside a computed property. While I understand that this is the correct approach, I am unsure of how to implement it. To provide a clearer understa ...

Ways to enable a user to edit a calculated property in VueJS?

I am currently working on collecting data that the user can download, and I am facing a challenge in determining the best way to handle the filename. To ensure the default filename is dynamic and based on the current date, I believe creating a computed pro ...

Creating efficient computed properties in React: a step-by-step guide

Currently, I am facing an issue with creating a table that contains checkboxes. This problem is quite frustrating, as demonstrated in the following example: I have a list of items in the format {id, value}. For each item, I generate a div element containi ...