You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/v2/guide/syntax.md
+19-16Lines changed: 19 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -46,9 +46,9 @@ The double mustaches interprets the data as plain text, not HTML. In order to ou
46
46
newVue({
47
47
el:'#example1',
48
48
data:function () {
49
-
return {
50
-
rawHtml:'<span style="color: red">This should be red.</span>'
51
-
}
49
+
return {
50
+
rawHtml:'<span style="color: red">This should be red.</span>'
51
+
}
52
52
}
53
53
})
54
54
</script>
@@ -130,37 +130,40 @@ Here the argument is the event name to listen to. We will talk about event handl
130
130
131
131
### Dynamic Arguments
132
132
133
-
> New in 2.6
133
+
> New in 2.6.0+
134
134
135
-
Starting in 2.6, it is also possible to use JavaScript expressions in an directive argument by wrapping it with square brackets:
135
+
Starting in version 2.6.0, it is also possible to use a JavaScript expression in a directive argument by wrapping it with square brackets:
136
136
137
137
```html
138
-
<av-bind:[key]="url"> ... </a>
138
+
<av-bind:[attributeName]="url"> ... </a>
139
139
```
140
140
141
-
Here `key` will be dynamically evaluated as a JavaScript expression, and its evaluated value will be used as the final value for the argument. For example, if your Vue instance has a data property`key` whose value is `"href"`, then this binding will be equivalent to `v-bind:href`.
141
+
Here `attributeName` will be dynamically evaluated as a JavaScript expression, and its evaluated value will be used as the final value for the argument. For example, if your Vue instance has a data property, `attributeName`, whose value is `"href"`, then this binding will be equivalent to `v-bind:href`.
142
142
143
-
Similarly, you can use dynamic arguments to bind a handler to a dynamic event:
143
+
Similarly, you can use dynamic arguments to bind a handler to a dynamic event name:
144
144
145
145
```html
146
-
<av-on:[event]="doSomething"> ... </a>
146
+
<av-on:[eventName]="doSomething"> ... </a>
147
147
```
148
148
149
+
Similarly, when `eventName`'s value is `"focus"`, for example, `v-on:[eventName]` will be equivalent to `v-on:focus`.
150
+
149
151
#### Dynamic Argument Value Constraints
150
152
151
-
Dynamic argument values are expected to be strings, with the exception of `null`. The special value `null` can be used to explicitly remove the binding. Any other non-string value will trigger a warning.
153
+
Dynamic arguments are expected to evaluate to a string, with the exception of `null`. The special value `null` can be used to explicitly remove the binding. Any other non-string value will trigger a warning.
152
154
153
155
#### Dynamic Argument Expression Constraints
154
156
155
-
<pclass="tip">Dynamic argument expressions have some syntax constraints because certain characters are invalid inside HTML attribute names, in particular spaces and quotes.</p>
157
+
<pclass="tip">Dynamic argument expressions have some syntax constraints because certain characters are invalid inside HTML attribute names, such as spaces and quotes.</p>
156
158
157
159
For example, the following is invalid:
158
160
159
161
```html
162
+
<!-- This will trigger a compiler warning. -->
160
163
<av-bind:['foo'+bar]="value"> ... </a>
161
164
```
162
165
163
-
The Vue template compiler will warn against such usage. The workaround is to either use expressions without spaces or quotes, or use a computed property instead.
166
+
The workaround is to either use expressions without spaces or quotes, or replace the complex expression with a computed property.
164
167
165
168
### Modifiers
166
169
@@ -174,7 +177,7 @@ You'll see other examples of modifiers later, [for `v-on`](events.html#Event-Mod
174
177
175
178
## Shorthands
176
179
177
-
The `v-` prefix serves as a visual cue for identifying Vue-specific attributes in your templates. This is useful when you are using Vue.js to apply dynamic behavior to some existing markup, but can feel verbose for some frequently used directives. At the same time, the need for the `v-` prefix becomes less important when you are building a [SPA](https://en.wikipedia.org/wiki/Single-page_application) where Vue.js manages every template. Therefore, Vue.js provides special shorthands for two of the most often used directives, `v-bind` and `v-on`:
180
+
The `v-` prefix serves as a visual cue for identifying Vue-specific attributes in your templates. This is useful when you are using Vue.js to apply dynamic behavior to some existing markup, but can feel verbose for some frequently used directives. At the same time, the need for the `v-` prefix becomes less important when you are building a [SPA](https://en.wikipedia.org/wiki/Single-page_application), where Vue manages every template. Therefore, Vue provides special shorthands for two of the most often used directives, `v-bind` and `v-on`:
178
181
179
182
### `v-bind` Shorthand
180
183
@@ -189,9 +192,9 @@ The `v-` prefix serves as a visual cue for identifying Vue-specific attributes i
189
192
<a:[key]="url"> ... </a>
190
193
```
191
194
192
-
>DOM Property Shorthand
195
+
####DOM Property Shorthand
193
196
194
-
In 2.6 a separate shorthand for explicit DOM property bindings (with the `.prop` modifier) have been introduced:
197
+
In 2.6.0+, a separate shorthand for explicit DOM property bindings (with the `.prop` modifier) have been introduced:
195
198
196
199
```html
197
200
<!-- full syntax -->
@@ -214,4 +217,4 @@ In 2.6 a separate shorthand for explicit DOM property bindings (with the `.prop`
214
217
<a@[event]="doSomething"> ... </a>
215
218
```
216
219
217
-
They may look a bit different from normal HTML, but `:` and `@` are valid chars for attribute names and all Vue.js supported browsers can parse it correctly. In addition, they do not appear in the final rendered markup. The shorthand syntax is totally optional, but you will likely appreciate it when you learn more about its usage later.
220
+
They may look a bit different from normal HTML, but `:` and `@` are valid characters for attribute names and all Vue-supported browsers can parse it correctly. In addition, they do not appear in the final rendered markup. The shorthand syntax is totally optional, but you will likely appreciate it when you learn more about its usage later.
0 commit comments