Skip to content

Commit 9e956b7

Browse files
brandedoutcastJinjiang
authored andcommitted
Update filters, global filters needs to go before Vue instance creation (#1392)
Global filters defined after creating the Vue instance throws `Failed to resolve filter`. Reference https://forum.vuejs.org/t/global-filters-failing-to-resolve-inside-single-file-components/21863/6
1 parent f822e38 commit 9e956b7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/v2/guide/filters.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@ filters: {
2626
}
2727
```
2828

29-
或者全局定义过滤器
29+
或者在创建 Vue 实例之前全局定义过滤器
3030

3131
``` js
3232
Vue.filter('capitalize', function (value) {
3333
if (!value) return ''
3434
value = value.toString()
3535
return value.charAt(0).toUpperCase() + value.slice(1)
3636
})
37+
38+
new Vue({
39+
// ...
40+
})
3741
```
3842

3943
下面这个例子用到了 `capitalize` 过滤器:

0 commit comments

Comments
 (0)