TRY AND ERROR

気になったこと、勉強したこと、その他雑記など色々メモしていきます。。Sometimes these posts will be written in English.,

VueJSでwatchが反応しない時

ちょっとハマった。
VueJSでwatchプロパティが反応しない場合があった。完全に反応しないのではなく特定の動作をした時に反応しなかった。
色々試してみたところv-ifなどでwatchプロパティを含む要素をdomから消した場合に反応しなかった。
逆に、domから消すのではなくv-showなどで非表示にすると動いた。

よく考えれば当たり前か。。




Struggled few moment...


Having Used VueJS, I had a problem which 'watch' property didn't react just in the specific case though It had reacted almost of all cases.The case is that the element which contains watch property is to be removed like using v-if.


Maybe if the element is not present, watch property of it cannot react at all. Contrarily It can react correctly when the element is just not visible(using v-show) rather than not exist.