Skip to content

Warn when v-model is bound on non-existent key #5932

@kay999

Description

@kay999

What problem does this feature solve?

Considering this binding:

<input type="text" v-model="data.val1">

This works fine if there is for example { data:{ val1:null }} defined in component-data, but if only { data:{} } is defined it doesn't work correctly because while val1 is created by v-model, it's not made reactive.

By using Vue.set for setting values, this wouldn't be a problem which would make live easiert for certain usecases.

What does the proposed API look like?

No visible change.

But to maintain the actual behaviour this could also be implemented using a modifier like 'set' for example:

<input type="text" v-model.set="data.val1">

This would use Vue.set(data, 'val1', ...) instead of simply generating data.val1 = ...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions