Skip to content

Commit ec99810

Browse files
committed
fix filter function examples, fixes #503
1 parent 1107e7b commit ec99810

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/guide/migration.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,9 @@ Use JavaScript's built-in [`.filter` method](https://developer.mozilla.org/en-US
907907
``` js
908908
computed: {
909909
filteredUsers: function () {
910-
return this.users.filter(function (user) {
911-
return user.name.indexOf(this.searchQuery) !== -1
910+
var self = this
911+
return self.users.filter(function (user) {
912+
return user.name.indexOf(self.searchQuery) !== -1
912913
})
913914
}
914915
}
@@ -917,8 +918,9 @@ computed: {
917918
JavaScript's native `.filter` can also manage much more complex filtering operations, because you have access to the full power of JavaScript within computed properties. For example, if you wanted to find all active users and case-insensitively match against both their name and email:
918919

919920
``` js
920-
this.users.filter(function (user) {
921-
var searchRegex = new RegExp(this.searchQuery, 'i')
921+
var self = this
922+
self.users.filter(function (user) {
923+
var searchRegex = new RegExp(self.searchQuery, 'i')
922924
return user.isActive && (
923925
searchRegex.test(user.name) ||
924926
searchRegex.test(user.email)

0 commit comments

Comments
 (0)