Comments (3)
[Boolean, String, Array]
In this case, the boolean operator has a higher precedence than the string. Therefore, it will evaluate to true.
from core.
This isn't happening by accident, it's intentional. There's an explicit check in the code for this specific case:
core/packages/runtime-core/src/componentProps.ts
Lines 568 to 569 in b2b5f57
core/packages/runtime-core/src/componentProps.ts
Lines 489 to 490 in b2b5f57
If Boolean
comes before String
then it'll behave like an HTML boolean attribute. So all of these would be considered true
:
<MyComp model-value />
<MyComp model-value="" />
<MyComp model-value="model-value" />
Likewise if ''
or 'model-value'
are passed with v-bind
.
Whether this is desirable or not, it has been that way since Vue 2, so it wouldn't be an easy thing to change at this point.
from core.
It's also documented behavior: https://vuejs.org/guide/components/props.html#boolean-casting
from core.
Related Issues (20)
- Parent component onUpdated() onBeforeUpdate() not performed HOT 3
- tsconfig project reference didn't support folder
- the derivation logic of generic HOT 1
- bug:子组件传参如果是个函数返回的对象,在父组件回调函数中对ref/reactive声明的变量赋值,如果该变量也在模版中使用,则会导致子组件所有接收的props每次都被重置 HOT 2
- Vue TSC & computed-refs HOT 3
- using symbol as a prop type throw error HOT 3
- Inconsistent behaviour in `Transition` component and lifecycle hooks like `onBeforeUnmount` and `onUnmounted` HOT 1
- toggle event throws error on details element HOT 1
- Radio input element's checked value not synced with props checked. HOT 4
- When using vue3, main.js automatically adds printing appz
- When using vue3, when main.js is running, the automatic addition of printing appz appears. HOT 1
- jsx 三元运算非预期 HOT 2
- vue webcomponent 里使用vue组件,组件内部样式丢失 HOT 3
- Failed to resolve import source when using PNPM
- scoped css [data="xyz"] is applied to wrong element HOT 2
- watchEffect 没触发 HOT 2
- Unintentional $event value setting on customized event HOT 2
- Blank screen when scaffolding project with ts (related to Vue Router) HOT 1
- Custom elements not able to associate with form HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.