Skip to content

Commit c601760

Browse files
committed
doc for v-style using object value
1 parent 9e6bbef commit c601760

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

source/api/directives.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,26 @@ Internally, {{ Mustache }} interpolations inside attributes
6363

6464
Apply inline CSS styles to the element.
6565

66-
When there is no argument, Vue.js will use the value to set `el.style.cssText`.
66+
When there is no argument, the bound value can either be a String or an Object.
67+
68+
- If it's a String, it will be set as the element's `style.cssText`.
69+
- If it's an Object, each key/value pair will be set on the element's `style` object.
70+
71+
**Example:**
72+
73+
``` html
74+
<div v-style="myStyles"></div>
75+
```
76+
77+
``` js
78+
// myStyles can either be a String:
79+
"color:red; font-weight:bold;"
80+
// or an Object:
81+
{
82+
color: 'red',
83+
fontWeight: 'bold'
84+
}
85+
```
6786

6887
When there is an argument, it will be used as the CSS property to apply. Combined with multiple clauses you can set multiple properties together:
6988

0 commit comments

Comments
 (0)