Skip to content

Commit 8c762d9

Browse files
committed
syntax guide tweaks for v2.6
1 parent 2908c49 commit 8c762d9

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/v2/guide/syntax.md

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ The double mustaches interprets the data as plain text, not HTML. In order to ou
4646
new Vue({
4747
el: '#example1',
4848
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+
}
5252
}
5353
})
5454
</script>
@@ -130,37 +130,40 @@ Here the argument is the event name to listen to. We will talk about event handl
130130

131131
### Dynamic Arguments
132132

133-
> New in 2.6
133+
> New in 2.6.0+
134134
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:
136136

137137
``` html
138-
<a v-bind:[key]="url"> ... </a>
138+
<a v-bind:[attributeName]="url"> ... </a>
139139
```
140140

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`.
142142

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:
144144

145145
``` html
146-
<a v-on:[event]="doSomething"> ... </a>
146+
<a v-on:[eventName]="doSomething"> ... </a>
147147
```
148148

149+
Similarly, when `eventName`'s value is `"focus"`, for example, `v-on:[eventName]` will be equivalent to `v-on:focus`.
150+
149151
#### Dynamic Argument Value Constraints
150152

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.
152154

153155
#### Dynamic Argument Expression Constraints
154156

155-
<p class="tip">Dynamic argument expressions have some syntax constraints because certain characters are invalid inside HTML attribute names, in particular spaces and quotes.</p>
157+
<p class="tip">Dynamic argument expressions have some syntax constraints because certain characters are invalid inside HTML attribute names, such as spaces and quotes.</p>
156158

157159
For example, the following is invalid:
158160

159161
``` html
162+
<!-- This will trigger a compiler warning. -->
160163
<a v-bind:['foo' + bar]="value"> ... </a>
161164
```
162165

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.
164167

165168
### Modifiers
166169

@@ -174,7 +177,7 @@ You'll see other examples of modifiers later, [for `v-on`](events.html#Event-Mod
174177

175178
## Shorthands
176179

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`:
178181

179182
### `v-bind` Shorthand
180183

@@ -189,9 +192,9 @@ The `v-` prefix serves as a visual cue for identifying Vue-specific attributes i
189192
<a :[key]="url"> ... </a>
190193
```
191194

192-
> DOM Property Shorthand
195+
#### DOM Property Shorthand
193196

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:
195198

196199
``` html
197200
<!-- full syntax -->
@@ -214,4 +217,4 @@ In 2.6 a separate shorthand for explicit DOM property bindings (with the `.prop`
214217
<a @[event]="doSomething"> ... </a>
215218
```
216219

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

Comments
 (0)