From 93ee1087247632627b97b6833f12de056de60762 Mon Sep 17 00:00:00 2001 From: Azamat Date: Sun, 31 May 2015 23:16:56 +0700 Subject: [PATCH] 'Multiple clauses' section in 'Custom directives' doc --- source/guide/custom-directive.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source/guide/custom-directive.md b/source/guide/custom-directive.md index 7bc86be178..edb150cc58 100644 --- a/source/guide/custom-directive.md +++ b/source/guide/custom-directive.md @@ -111,6 +111,26 @@ var demo = new Vue({ }) +### Multiple Clauses + +Comma separated arguments are bound as multiple directive instances. In the following example, directive methods are called twice: + +``` html +
+``` + +You can achieve single binding with all arguments by closing value with object literal: + +``` html +
+``` + +``` 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.