Skip to content

Sync Modifier support object properties #6241

@altjz

Description

@altjz

What problem does this feature solve?

Sync Modifier support object properties.
For example, I have a myObj object, it has a foo and a bar property.

myObj: {
  foo: 'foo',
  bar: 'bar'
}

This feature could use update:myObj.foo and update:myObj.bar to update the value.

this.$emit('update:myObj.foo', 'new-foo');
this.$emit('update:myObj.bar', 'new-bar');

What does the proposed API look like?

Currently, I need to use below format

<MyComponent :foo.sync="myObj.foo" :bar.sync="myObj.bar"></MyComponent>
props: ['foo', 'bar']
...
this.$emit('update:foo', 'new-foo');
this.$emit('update:bar', 'new-bar');

But with this new feature:

<MyComponent :myObj.sync="myObj"></MyComponent>
props: ['myObj']
...
this.$emit('update:myObj.foo', 'new-foo');
this.$emit('update:myObj.bar', 'new-bar');

It becomes more simple and clear, especially when the object has many properties.

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