search

Home  >  Q&A  >  body text

javascript - How to trigger watch during vue initialization


How to trigger this watch event in created

三叔三叔2695 days ago1063

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-07-05 10:59:55

    Convert the method of consideration from [how to trigger this event in created] to [how to encapsulate this logic and then trigger it in created], and you will have the answer:

    1. Encapsulate the logic in watch into a function in methods.

    2. Call the methods function in created.

    In this way, the requirements are achieved without losing reusability.

    reply
    0
  • Cancelreply