D
D
Denis Bukreev2018-10-11 12:24:51
Vue.js
Denis Bukreev, 2018-10-11 12:24:51

DOM not updating after changing VueJS data - why?

There is a component that takes a campaign object from the state .
In the created component, based on the properties of the object, I create another property of this object:

this.campaign.status = this.campaign.schedule ? 'dates' : 'now'; // новое свойство

The template has code that depends on the new property and changes it (using radio buttons):
<app-radio name="schedule"
           :value="campaign.status == 'now'"
           @input="campaign.status = 'now'"
></app-radio>
<app-radio name="schedule"
           :value="campaign.status == 'dates'"
           @input="campaign.status = 'dates'"
></app-radio>

<span>{{campaign.status}}</span>

The last line is just to shorten the code - there is a cumbersome block that is shown depending on this status.
And the problem is that when the radio button is switched, nothing happens on the page, except for switching the radio button, although the text in the span described at the end of the code should change.
At the same time, exactly the same block of code, but with a different property, works fine and the text changes. The difference is that this other property is native to this campaign object , rather than being set on created .
I also noticed that the reaction to changing the status property occurs after changing any other property of the campaign object .
What do I miss in my work? Why is this happening?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-10-11
@denisbookreev

In this case, exactly the same block of code, but with a different property, works fine and the text changes. The difference is that this other property is native to this campaign object, rather than being set on created.

It's clear. You obviously think that you don't need to read the documentation. You are wrong. Read .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question