W
W
WebDev2017-08-25 12:34:22
Vue.js
WebDev, 2017-08-25 12:34:22

Bugs in vue.js?

Hello, I am using vuex to store data. In mutations added a method that fills an array with numbers. Before filling, I bring each value to the parseInt () number. But when I get this array, all the numbers in it are strings. Who faced?
The next bug is related to changing the data. In the same vuex there is an object where the keys are the product id and the value is the product itself. When adding a new product to the mutation, I do this
state.products[product.id] = product;
. In the application code, these changes are not tracked.

//Не работает вот так
<span v-if="$store.state.products[id]"></span>
//И вот так
computed: {
    productExists: function(id) {
        return this.$store.state.products[id];
    }
}

In general, what mysticism is with these trackings. It either works or it doesn't. I checked it - it works, I went and wrote it like that everywhere, and then suddenly it doesn’t work and change it everywhere again. Very exhausting ...
Is it a bug or am I doing something wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2017-08-25
@kirill-93

When adding a new product to a mutation, it is necessary to assign an updated array to the property or use overridden methods to preserve reactivity, they write about this in the documentation
There are not thousands of products

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question