vue icon indicating copy to clipboard operation
vue copied to clipboard

Provide a way to define different name for prop attribute

Open davletovalmir opened this issue 6 years ago • 17 comments

What problem does this feature solve?

In most of cases, it's not really comfortable to use initialProp as prop name, for example, or have normalizedProp inside a component, which takes some passed prop and transforms it. Code looks bloated and reminds more workaround than a good solution.

Having ability to change attribute name of prop would be great. Something like:

rawProp: { attributeName: "prop" }

What does the proposed API look like?

<component size="md"> ... </component>
computed: {
  size: {
    switch (this.rawSize) { ... } // returns something in case blocks
  }
},
props: {
  rawSize: {
    attributeName: "size",
    type: String
  }
}

Thus, using any of proposed solutions above, this.size inside component would return transformed value (for example, h4 or just 4).

I believe having this feature would be very awesome and help us to write cleaner code.

davletovalmir avatar Apr 01 '18 21:04 davletovalmir