Questions tagged [computed-properties]
Computed properties are functions declared as property. There are multiple languages supporting computed properties, so please use this tag in combination with tags like [swift], [javascript], etc.
527
questions
0
votes
1
answer
49
views
vue 3: how to use computed based on props
I try to compute a value based on a props value like this:
interface Props {
task: Task;
}
const totalPrice = computed(() => {
return task.paymentDetail.products
.map(p => p.amount)
...
0
votes
0
answers
24
views
nuxt Vue Components, computed value is "undefined"
I am trying to get data through NUXT Api.
also want to return it to the computed property.
I'm sure I missed some stupid mistake or something simple.
I appreciate help.
async asyncData ({ app, params }...
0
votes
1
answer
31
views
How to get data from axios call in computed method to manipulate them?
I do a call with axios to get data like this:
export default {
name: 'TaxesSection',
data () {
return {
isFormShown: false,
isLoading: false,
isOpen:...
0
votes
2
answers
43
views
VueUse useDark() does not trigger computed or watch
import { useDark } from '@vueuse/core';
const isDark = useDark();
watch(isDark, () => {
console.log('dark mode changed'); // does not trigger watch
}, { deep: true })
const scheme = computed(...
0
votes
1
answer
22
views
how to render only a certain set of data in a sub-array with VueJS
I have this problem where i have a set of JSON format files that look like this :
{
"_id" : "name_id",
"apkMode" : "SCROLL",
"date" : "2022-04-...
0
votes
1
answer
41
views
Show new value of computed property without refreshing in Vue 3
I am using Vue3 to develop the frontend part of a web application about films. In this app, the user has a list of those films he has already watched. To add a movie to the list, the user finds a film,...
0
votes
1
answer
18
views
Vue computed properties are not being called
Vue computed properties are not being called.
Here is the code :
import Assignment from "./Assignment.js";
export default {
components: { Assignment },
template: `
<...
0
votes
0
answers
56
views
Uncaught ReferenceError: firstSelectAll is not defined
I have this table with checkboxes. I use computed property in <th> v-model to check all the checkboxes in <td>
The problem is with my development it is working perfectly, but in deployment/...
0
votes
1
answer
43
views
How do add this external script into Vuejs
I have this script
<script id="id" src="link"> </script>
How do I convert this using a computed or @click function?
1
vote
0
answers
34
views
vue3 two-way bind nested json best practice
i have the following JSON response from a REST API
{
"data": {
"name": "data 123",
"prop1" : "abc",
"prop2" : "xyz",
...
0
votes
0
answers
167
views
My computed property is not updating (composables)
I'm starting to use Vue 3 and composables. However, it seems that the computed properties that depends on variables (or computed properties) in other composables are not updating.
This is my first ...
0
votes
1
answer
22
views
why Vue compute don't call get after setting dependent value in set function?
I define a computed value as bellow
template :
<date-picker
v-model="rangeDate"
type="date"
format="jYYYY/jMM/jDD"
...
0
votes
1
answer
44
views
Execution of combined Booleans in swift
I'm having a question about a computed property where I'm using a combination of computed Booleans to get a result. I understand the logic behind the code, but I'm using some print statements in my ...
0
votes
0
answers
257
views
vue3 resuable computed properties
I tried creating Singleton service files with vue3 to have reusable computed properties (define once , then just reuse on every other call)
Normally with composition api pattern each time you do useX()...
0
votes
1
answer
35
views
How to use maps and enumerations for property names in typescript?
The object pulsarAlert is returning with type [x: string] : string
Ideally it should be able to detect that if channel = "SMS" then notificationType = "phone", if channel = "...
1
vote
0
answers
26
views
How does Vue's "computed" know which fields were updated? [closed]
I've created this minimal example to show what I do not understand about reactivity engine of Vue.
<script setup>
import { ref, computed } from 'vue'
const obj = ref({
some: {
value: 1,
...
0
votes
0
answers
170
views
Vue 3 Assign value to computed property from array
I have a problem assigning the correct value to my computed property. I want the computed property answerHistory to return correctAnswer for the current question.
This is my JSON
[
{
"...
0
votes
1
answer
85
views
F#: How can I define a computed property in a type?
In C#, I can define a computed property as such:
public class MyViewModel
{
public DateTime StartDate { get; set; }
public string StartDateFormatted => StartDate.ToString("yyyy.MM.dd h:...
0
votes
1
answer
20
views
Error filtering an array with my search bar vuejs2
I'm trying to filter an array, which is cycled in a v-for, by using a search bar and i don't know why everything just disappear.I am currently cycling the function searchedRestaurant().
This is the ...
0
votes
1
answer
62
views
Bootstrap check box not updating on Computed Properties
I'm trying to create a checkbox that selects all checkboxes.
I have an array of objects. Inside each object is a allowed value. Which states if a checkbox is active. The array is coming from a ...
3
votes
2
answers
376
views
Can not catch Vuex state change in my Vue component
I have a Vuex store where I have a getter which works correctly and I can see the changes on the state. But if I call this getter as computed property in component it does not work. The value is still ...
0
votes
0
answers
202
views
Nuxt / Vuex: use async getter in another computed property
Store / actions.js
export default {
async fetchData(context, route) {
const dataURL = `myUrl.json`;
const response = await fetch(dataURL);
const responseData = await response.json();
...
1
vote
0
answers
125
views
Open a date picker from inside a v-select VUE
I have a v-select with four items to choose different dates. The last item in the select is for choosing a manual date and then I want a menu/dialog to pop open with a date picker. But I can't get ...
2
votes
1
answer
118
views
How to define a infinite Lazy List using a given function or property in Scala?
I recently was seeing an advanced Scala course in Rock the JVM and, in one lesson, Daniel purposed to create a set using propertys (functions going from A to Boolean), the implementation of this Set ...
0
votes
0
answers
24
views
Filter dates and move back and forth VUE
I have a select where I filter tasks on week, month and year and it works fine. But I want to have a buttons next to the select where I can move to the previous or next week (If I'm filtering on week, ...
0
votes
0
answers
48
views
Vue.js How can I read the array values in [__ob__: Observer]
I need to create an array which will read 4 values of type string and after that it will pass in a graph to create its columns.
This is my array bellow (poo: []) :
data() {
return {
graphicData: {
...
0
votes
1
answer
29
views
VUEJS/X Data Template loads before my computed
first of all I'm sorry for my bad English, I'm using a translator.
I'm a beginner with VUE and VUE X, there are surely big mistakes.
I have a problem with VUE, currently I am trying to display a ...
0
votes
0
answers
38
views
Filter in vue computed
I have a dashboard with different leads that are also sorted under different statuses.
For now all the different leads get sorted under the different statuses and it looks like this in my setup(). The ...
1
vote
1
answer
96
views
Swift Reference Cycle When Capturing A Computed String Property Declared From Inside An Instance Method
I'm implementing an in-game store using Swift and SpriteKit. There is a class called Store which has a method setupItems() inside of which we declare and instantiate instances of a class StoreItem and ...
0
votes
1
answer
787
views
How to trigger a Vue method when computed property changes
Essentially, in a Vue application, I have a page that lists Contacts. And a search form that is part of a header component. I capture the input search term as a state variable in the vuex store and ...
0
votes
1
answer
106
views
Why vue computed property doesn't become reaective?
Some part of my script setup:
const storyVideo = ref("storyVideo")
const topBar = computed(() => {
return 'background-position: ' + (storyVideo?.value?.currentTime / store....
0
votes
0
answers
110
views
computed property "for get" and "for set"
i want to manipulate a object without really modify it, every time i try to modify it, i create a new "object modifier" and modify it, every time i try to read my object if there's a ...
1
vote
1
answer
164
views
how to get a deep computed value
i have this deep getter:
getTotalVideoLength: {
cache: false,
get() {
let duration = 0;
_.forEach(this.videos, (video) => {
...
1
vote
1
answer
130
views
Is It Inefficient To Access A Static Property Through Computed Properties In Swift?
Say I have some constants that should be treated as class variables.
static let constant1 = 1
static let constant2 = 2
static let constant3 = 3
In order to access constant1, I need to go thru the ...
0
votes
1
answer
149
views
How to watch nested Vuex store values
I have a Vue project where I need to watch some Vuex store values. Here is the code:
computed: {
serverCategories: {
get() {
return this.$store.state[this.storeName]....
1
vote
2
answers
136
views
Calculate completed percentage
I have an array of different progress statuses and the current status. I want to be able to display the completed percentage. So far I have this:
getCompletedPercentage(): Status | undefined | ...
0
votes
1
answer
386
views
Vue.js: Conditional Rendering Array Using Computed Property
I'm new to Vue and have spent the past several hours looking into how to use conditional logic within methods and computed properties for a practice project creating a birthday component. I've seen ...
0
votes
2
answers
538
views
Swift binding to a computed property
Have the following situation. I have a view model that is an observable object with a computed property of type Bool. I want to be able to enable/disable a navigation link based on the computed ...
0
votes
1
answer
55
views
"xx" is get-only property - How to Assign decoded Json Data to class (nested view model) Swift
I have a watchapp that receives parent view model (nested view model) data from iPhone via json/file transfer. I am using "Communicator" library by @KaneCheshire.
The data flow is
Watch App ...
1
vote
1
answer
164
views
computed property names and this - JS
Can i use this in computed property name ?
something like this:
class User {
constructor(username) {
this._username = username;
}
[this._username + "Print"]() {
console.log(...
0
votes
1
answer
263
views
Return different values from computed Vue
I have buttons to set different dates (one for tomorrow and one for in a week) and have made a function for only calculating business days. So the 'tomorrow' button should show either 'Tomorrow' or '...
1
vote
1
answer
84
views
Why doesn't window.getComputedStyle invoke recalculate styles and reflow?
Look at this example:
const startTime = performance.now();
setTimeout(() => console.log(`taken time: ${performance.now() - startTime}ms`))
for(let i = 0; i < 1000; i++){
const element = ...
0
votes
1
answer
90
views
How can I rerender when object (a dictionary) changes?
I have the following .hbs
<button {{action "addToObject"}}>
Add to Object
</button>
<br />
{{#each this.sortedDictionary as |item|}}
{{item.name}}<br />
{{/...
0
votes
1
answer
352
views
how to run side effect on value change in Vue.js?
my goal is to run a sideeffect when the "monthIndex" changes. In react I would use a useEffect hook with the dependency, but I am new to vue. I am basically incrementing the "monthIndex&...
0
votes
1
answer
160
views
How to acces a computed property from a method in Vue.js
I'm trying to acces to the "generatedOrder" object from a method called "onSubmit()". This object was previously commited to the store from another component and it is fetched with ...
1
vote
1
answer
766
views
How to use `mapGetters` in the computed section only, without passing it to data ? And what name should I pass to the set?
This is a screenshot from another question about mapGetters
Link to the question I took the screen from
In Vue.js I saw an answer to a post.
It said :
In your Component
computed: {
......
1
vote
1
answer
63
views
Computed property to sum numeric arrays in Swift
Task from book says: without calling reduce(_: _:) method, sum sequences of numbers by adding a computed property called sum. You should be able to use it like this:
[3, 7, 7].sum // 17
[8....
0
votes
2
answers
72
views
Navigation component not getting re rendered with stage change in Vue3
When a user updates their username in the EditAccount component, the username is updated in the EditAccount component and in vuex store but not in the Navigation component even though stage change is ...
0
votes
1
answer
49
views
Create kind of carousel Vue
So, I have a dashboard where I want to display some cards. There should only be four visible at a time and when clicking on the arrow you just want to move one step to the next card. So let's say ...
0
votes
1
answer
109
views
Vue.js computed property showing wrong data
I have a leaflet project and I am using a Vue computed property to show the coordinates of a layer. I am implementing functionality to edit the coordinates directly in the block that renders the ...