Answer the question
In order to leave comments, you need to log in
Why does observation work so strangely?
Greetings.
There is a component:
<div id="app">
<my-component>
</my-component>
</div>
const MyComponent = {
template: '<div>{{x}}<br>{{y}}</div>',
data() {
return {
x: '',
y: '',
isOk: false
}
},
created(){
alert(this.isOk);
this.x = 'x-first';
this.y = 'y-first';
alert(this.isOk);
this.isOk = true;//теперь наблюдаем
},
watch: {
x(){
this.check();
},
y(){
this.check();
}
},
methods: {
check(){
alert('watch ' + this.isOk);
}
}
};
false
false
watch true
watch true
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question