New shorthand: !prop
-> :prop="false"
#777
Replies: 3 comments
-
支持 |
Beta Was this translation helpful? Give feedback.
-
Why
|
Beta Was this translation helpful? Give feedback.
-
I literally came here to suggest this feature lol. Been thinking about it for a while |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Linked issues: vuejs/vue#8549
Summary
This RFC proposes a shorthand syntax for binding variables with
false
value.Base example
Motivation
For props without values, we have already implicitly set its value to
true
. For components, the default value of an optional boolean property isfalse
, this way of writing can concisely enable the property. However, in actual application scenarios, it is difficult for us to design a set of boolean properties with all default values set tofalse
for a component. For the code simplicity, it is common for properties with default values of eitherfalse
ortrue
to coexist. With this shorthand, we gain the ability to quickly set a property to eithertrue
orfalse
.Detailed design
In contrast to
prop
->:prop="true"
,!prop
->:prop="false"
.Drawbacks
Alternatives
Adoption strategy
Unresolved questions
Beta Was this translation helpful? Give feedback.
All reactions