Skip to content

Clarify falsy conditions for attribute description #1271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/v2/guide/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,20 @@ The contents of this `div` will be replaced with the value of the `rawHtml` prop

### Attributes

Mustaches cannot be used inside HTML attributes, instead use a [v-bind directive](../api/#v-bind):
Mustaches cannot be used inside HTML attributes. Instead, use a [v-bind directive](../api/#v-bind):

``` html
<div v-bind:id="dynamicId"></div>
```

It also works for boolean attributes - the attribute will be removed if the condition evaluates to a falsy value:
In the case of boolean attributes, where their mere existence implies `true`, `v-bind` works a little differently. In this example:

``` html
<button v-bind:disabled="isButtonDisabled">Button</button>
```

If `isButtonDisabled` has the value of `null`, `undefined`, or `false`, the `disabled` attribute will not even be included in the rendered `<button>` element.

### Using JavaScript Expressions

So far we've only been binding to simple property keys in our templates. But Vue.js actually supports the full power of JavaScript expressions inside all data bindings:
Expand Down