Skip to content

Commit cebec20

Browse files
committed
Merge pull request vuejs#21 from luin/lang-zh
翻译 api/filters.md
2 parents ab61899 + c0e3a17 commit cebec20

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

source/api/filters.md

+26-26
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ order: 7
1717

1818
### currency
1919

20-
- this filter takes one optional argument
20+
- 这个 filter 接受一个可选参数
2121

2222
*12345 => $12,345.00*
2323

24-
You can pass an optional argument which will be used as the currency symbol (default is $).
24+
你可以传递一个可选参数来表示货币符号
2525

2626
### pluralize
2727

28-
- this filter takes at least one argument
28+
- 这个 filter 接受至少一个参数
2929

30-
Pluralizes the argument based on the filtered value. When there is exactly one arg, plural forms simply add an "s" at the end. When there are more than one argument, the arguments will be used as array of strings corresponding to the single, double, triple ... forms of the word to be pluralized. When the number to be pluralized exceeds the length of the args, it will use the last entry in the array.
30+
根据要处理的值来将参数转换为复数。当只有一个参数时,其复数形式就是在参数末尾加上“s”。当参数多于一个时,所有的参数将会以字符串数组的形式对应要被转换为复数的单词的“一倍”、“两倍”、“三倍”......形式。当复数的数量超过参数个数时,会使用最后一个参数。
3131

32-
**Example:**
32+
**例子:**
3333

3434
``` html
3535
{{count}} {{count | pluralize item}}
@@ -42,7 +42,7 @@ Pluralizes the argument based on the filtered value. When there is exactly one a
4242
{{date}}{{date | pluralize st nd rd th}}
4343
```
4444

45-
Will result in:
45+
结果为:
4646

4747
*1 => '1st'*
4848
*2 => '2nd'*
@@ -52,20 +52,20 @@ Will result in:
5252

5353
### json
5454

55-
- this filter takes one optional argument
55+
- 这个 filter 接受一个可选参数
5656

57-
JSON.stringify() incoming value rather than outputting the string representation (i.e. `[object Object]`). It also takes one optional argument which is the indent level (defaults to 2):
57+
使用 `JSON.stringify()` 来处理值而不是直接将其字符串化(如 `[object Object]`)。这个 filter 接受一个可选参数来指定缩进级别(默认是 2)。
5858

5959
``` html
6060
<pre>{&#123;$data | json 4&#125;}</pre>
6161
```
6262

6363
### key
6464

65-
- this filter only works in `v-on`
66-
- this filter takes exactly one argument
65+
- 这个 filter 只工作于 `v-on`
66+
- 这个 filter 接收一个参数
6767

68-
Wrap the handler so it only gets called when the keyCode matches the argument. You can also use string aliases for a few commonly-used keys:
68+
包裹 handler 使得其仅在 keyCode 是指定的参数时才被调用。你也可以使用几个常用键值的别名:
6969

7070
- enter
7171
- tab
@@ -76,22 +76,22 @@ Wrap the handler so it only gets called when the keyCode matches the argument. Y
7676
- left
7777
- right
7878

79-
**Example:**
79+
**例子:**
8080

8181
``` html
8282
<input v-on="keyup:doSomething | key enter">
8383
```
8484

85-
`doSomething` will only be called when the Enter key is pressed.
85+
只有按回车键(enter)时才会调用 `doSomething`
8686

8787
### filterBy
8888

89-
**Syntax:** `filterBy searchKey [in dataKey]`.
89+
**语法:** `filterBy searchKey [in dataKey]`.
9090

91-
- this filter only works in `v-repeat`
92-
- this is a computed filter
91+
- 这个 filter 只工作于 `v-repeat`
92+
- 这是一个 computed filter
9393

94-
Make `v-repeat` only display a filtered version of the source Array. The `searchKey` argument is a property key on the context ViewModel. The value of that property will be used as the string to search for:
94+
使得 `v-repeat` 只显示数组过滤后的结果。`searchKey` 参数是当前 ViewModel 的一个属性名。这个属性的值会被用作查找的目标:
9595

9696
``` html
9797
<input v-model="searchText">
@@ -100,9 +100,9 @@ Make `v-repeat` only display a filtered version of the source Array. The `search
100100
</ul>
101101
```
102102

103-
When the filter is applied, it will filter the `users` Array by recursively searching for the current value of `searchText` on each item in the Array. For example, if an item is `{ name: 'Jack', phone: '555-123-4567' }` and `searchText` has value `'555'`, the item will be considered a match.
103+
当使用这个 filter 时,将递归遍历 `users` 数组的每一个元素来寻找 `searchText` 的当前值从而过滤该数组。举例来说,如果一个条目是 `{ name: 'Jack', phone: '555-123-4567' }`,而 `searchText` 的值是 `'555'`,这个条目就被认为是符合条件。
104104

105-
Optionally, you can narrow down which specific property to search in with the optional `in dataKey` argument:
105+
可选地,你可以通过 `in dataKey` 参数来指定具体要查找哪个属性:
106106

107107
``` html
108108
<input v-model="searchText">
@@ -111,9 +111,9 @@ Optionally, you can narrow down which specific property to search in with the op
111111
</ul>
112112
```
113113

114-
Now the item will only match if the value of `searchText` is found in its `name` property. So `searchText` with value `'555'` will no longer match this item, but `'Jack'` will.
114+
现在只有当 `name` 属性包含 `searchText` 时这个条目才符合条件。所以当 `searchText` 的值是 `'555'` 时这个条目将不符合条件,而当值是 `'Jack'` 时即符合。
115115

116-
Finally, you can use quotes to indicate literal arguments:
116+
最后,你可以使用引号来表示字面量参数:
117117

118118
``` html
119119
<ul>
@@ -123,12 +123,12 @@ Finally, you can use quotes to indicate literal arguments:
123123

124124
### orderBy
125125

126-
**Syntax:** `orderBy sortKey [reverseKey]`.
126+
**语法:** `orderBy sortKey [reverseKey]`.
127127

128-
- this filter only works in `v-repeat`
129-
- this is a computed filter
128+
- 这个 filter 只工作于 `v-repeat`
129+
- 这是一个 computed filter
130130

131-
Sort `v-repeat`'s displayed result. The `sortKey` argument is a property key on the context ViewModel. The value of that property will be used as the key to sort the Array items with. The optional `reverseKey` argument is also a property key on the context ViewModel, but the value's truthiness will determine whether the result should be reversed.
131+
`v-repeat` 的结果排序。`sortKey`参数是当前 ViewModel 的一个属性名。这个属性的值表示用来排序的键名。可选的 `reverseKey` 参数也是当前 ViewModel 的一个属性名,如果这个属性值为真则数组会被倒序排列。
132132

133133
``` html
134134
<ul>
@@ -146,7 +146,7 @@ new Vue({
146146
})
147147
```
148148

149-
You can also use quotes for literal sort key. To indicate a literal reverse, use `-1`:
149+
你可以使用引号来表示字面量的排序键名。使用 `-1` 来表示字面量的 `reverse` 参数。
150150

151151
``` html
152152
<ul>

0 commit comments

Comments
 (0)