LoginSignup
0
1

More than 3 years have passed since last update.

[Vue.js]watch

Posted at

watchはどんな時に使うのか

あるデータが変わった時に特定の処理をしたい時に使う 主に非同期処理の時に使用する

 watch:{
//numが変わった時にどんな処理をしたいか
   num:function(){
//非同期処理ではthisを使えないため最初にthisを他に代入しておく
     const vm = this
     setTimeout(function(){
//numを0にする
        vm.num = 0
//2秒後に
        },2000)
        }

理解が怪しいため間違ってるかも。。。また勉強して更新しよう。。。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1