Vue.js 3 | How Reusable Components Work with One v-model ? (under 3 Minutes) Part 1

Поделиться
HTML-код
  • Опубликовано: 16 ноя 2024

Комментарии • 7

  • @julienSibille
    @julienSibille Год назад +2

    You could also place the @input on the component in the parent, and not having to emit from the child

  • @lumcodex
    @lumcodex Год назад

    the visualization is so good, ty

  • @nguyenbao-j8l
    @nguyenbao-j8l Год назад

    i love your video

  • @AlouiMohamedhabib
    @AlouiMohamedhabib 7 месяцев назад

    Careful with mutating the parent props!

  • @captainlennyjapan27
    @captainlennyjapan27 Год назад

    Really wonering - what is the advantage of using v-model compared to prop & emit pattern?
    Thanks for the amazing video but im still quite confused with the above

    • @David-gj6dc
      @David-gj6dc 7 месяцев назад

      They are pretty much the same from my understanding, just in a more terse syntax. Like the video explains, v-model is just a shorthand for a prop and emit handler which just updates the value.
      One implication from a code structure standpoint is if you need to run other code as well as updating the state on each emit, you now need a watcher to do that. Before you could just inline the code inside the handler function. This theoretically COULD matter if the order of execution matters.