Vue: Watch immediate=true has no effect when declared in component options

Created on 12 Dec 2017  路  2Comments  路  Source: vuejs/vue

Version

2.5.9

Reproduction link

https://jsfiddle.net/Toilal/q976rqrw/

Steps to reproduce

Open JSFiddle and see

What is expected?

Handler from component options should be invoked immediatly like handler from $watch method

What is actually happening?

Handler from component options is not invoked initially

Most helpful comment

For watch option, just write in this way:

watch: {
  message: {
    immediate: true,
    handler: function ()聽{
      ...
    }
  }
}

https://jsfiddle.net/q976rqrw/4/

All 2 comments

For watch option, just write in this way:

watch: {
  message: {
    immediate: true,
    handler: function ()聽{
      ...
    }
  }
}

https://jsfiddle.net/q976rqrw/4/

Oops sorry for noise. Strange that TypeScript didn't catched this though.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yyx990803 picture yyx990803  路  48Comments

eu81273 picture eu81273  路  40Comments

smolinari picture smolinari  路  116Comments

wenLiangcan picture wenLiangcan  路  39Comments

ferry77 picture ferry77  路  67Comments