Skip to content

Implicit parent-child communication is misleading #859

Closed
@mgibas

Description

@mgibas

Documentations states that this:

app.component('TodoItem', {
  props: {
    todo: {
      type: Object,
      required: true
    }
  },

  template: '<input v-model="todo.text">'
})

should be converted to this:

app.component('TodoItem', {
  props: {
    todo: {
      type: Object,
      required: true
    }
  },

  template: `
    <input
      :value="todo.text"
      @input="$emit('input', $event.target.value)"
    >
  `
})

Assuming it has same functional goal this is not true - if parent of this component will pass todo through ie v-model then input event will override passed todo model with a string ($event.target.value). If parent is not using v-model but simply :todo="todo" then how would it know that $emit('input', $event.target.value) corresponds to text property of provided model ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions