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
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -95,15 +95,15 @@ Here, the `v-if` directive would remove/insert the `<p>` element based on the tr
95
95
Some directives can take an "argument", denoted by a colon after the directive name. For example, the `v-bind` directive is used to reactively update an HTML attribute:
96
96
97
97
```html
98
-
<av-bind:href="url"></a>
98
+
<av-bind:href="url"> ... </a>
99
99
```
100
100
101
101
Here `href` is the argument, which tells the `v-bind` directive to bind the element's `href` attribute to the value of the expression `url`.
102
102
103
103
Another example is the `v-on` directive, which listens to DOM events:
104
104
105
105
```html
106
-
<av-on:click="doSomething">
106
+
<av-on:click="doSomething"> ... </a>
107
107
```
108
108
109
109
Here the argument is the event name to listen to. We will talk about event handling in more detail too.
@@ -113,7 +113,7 @@ Here the argument is the event name to listen to. We will talk about event handl
113
113
Modifiers are special postfixes denoted by a dot, which indicate that a directive should be bound in some special way. For example, the `.prevent` modifier tells the `v-on` directive to call `event.preventDefault()` on the triggered event:
114
114
115
115
```html
116
-
<formv-on:submit.prevent="onSubmit"></form>
116
+
<formv-on:submit.prevent="onSubmit"> ... </form>
117
117
```
118
118
119
119
You'll see other examples of modifiers later, [for `v-on`](events.html#Event-Modifiers) and [for `v-model`](forms.html#Modifiers), when we explore those features.
@@ -126,20 +126,20 @@ The `v-` prefix serves as a visual cue for identifying Vue-specific attributes i
126
126
127
127
```html
128
128
<!-- full syntax -->
129
-
<av-bind:href="url"></a>
129
+
<av-bind:href="url"> ... </a>
130
130
131
131
<!-- shorthand -->
132
-
<a:href="url"></a>
132
+
<a:href="url"> ... </a>
133
133
```
134
134
135
135
### `v-on` Shorthand
136
136
137
137
```html
138
138
<!-- full syntax -->
139
-
<av-on:click="doSomething"></a>
139
+
<av-on:click="doSomething"> ... </a>
140
140
141
141
<!-- shorthand -->
142
-
<a@click="doSomething"></a>
142
+
<a@click="doSomething"> ... </a>
143
143
```
144
144
145
145
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.
0 commit comments