Skip to content

'Multiple clauses' section in 'Custom directives' doc #74

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 1 commit into from
May 31, 2015
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
20 changes: 20 additions & 0 deletions source/guide/custom-directive.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ var demo = new Vue({
})
</script>

### Multiple Clauses

Comma separated arguments are bound as multiple directive instances. In the following example, directive methods are called twice:

``` html
<div v-demo="color: 'white', text: 'hello!'"></div>
```

You can achieve single binding with all arguments by closing value with object literal:

``` html
<div v-demo="{color: 'white', text: 'hello!'}"></div>
```

``` js
Vue.directive('demo', function (value) {
console.log(value) // Object {color: 'white', text: 'hello!'}
})
```

## Literal Directives

If you pass in `isLiteral: true` when creating a custom directive, the attribute value will be taken as a literal string and assigned as that directive's `expression`. The directive will not attempt to setup data observation.
Expand Down