Skip to content

Commit 3df848e

Browse files
committed
Update custom-directive.md
1 parent 479eb84 commit 3df848e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

source/guide/custom-directive.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,19 @@ Vue.directive('literal-dir', {
161161
### 动态直接量
162162

163163
However, in the case that the literal directive contains mustache tags, the behavior is as follows:
164+
164165
然而,在直接指令含有mustache标签的情形下,指令的行为如下所示:
165166

166167
- The directive instance will have a flag `this._isDynamicLiteral` set to `true`;
168+
167169
- 指令实例会有一个标记,`this._isDynamicLiteral` 被设为 `true`
168170

169171
- If no `update` function is provided, the mustache expression will be evaluated only once and assigned to `this.expression`. No data observation happens.
172+
170173
- 如果没有提供 `update` 函数,mustache表达式只会被计算一次,并将值赋给 `this.expression` 。不会对表达式进行数据监视。
171174

172175
- If an `update` function is provided, the directive **will** setup data observation for that expression and call `update` when the evaluated result changes.
176+
173177
- 如果提供了 `update` 函数,指令****会为表达式建立一个数据监视,并且在计算结果变化的时候调用 `update`
174178

175179
## Two-way Directives
@@ -202,6 +206,7 @@ Vue.directive('example', {
202206
## 内联声明
203207

204208
Passing in `acceptStatement:true` enables your custom directive to accept inline statements like `v-on` does:
209+
205210
传入 `acceptStatement:true` 可以让自定义指令像 `v-on` 一样接受内联声明:
206211

207212
``` html
@@ -220,6 +225,7 @@ Vue.directive('my-directive', {
220225
```
221226

222227
Use this wisely though, because in general you want to avoid side-effects in your templates.
228+
223229
但是要聪明地使用它,因为通常情况下你是想避免它在你的模板中产生副作用。
224230

225231
## Deep Observation
@@ -255,4 +261,5 @@ You can checkout the priorities for some built-in directives in the [API referen
255261
你可以去[API reference](../api/directives.html)看一些内置指令的优先级。另外,`v-repeat`, `v-if` 以及 `v-component` 被视为“终端指令”,它们在编译过程中始终拥有最高的优先级。
256262

257263
Next, we'll see how to [write a custom filter](../guide/custom-filter.html).
264+
258265
下面,我们来看怎样写一个[自定义过滤器](../guide/custom-filter.html)

0 commit comments

Comments
 (0)