$t is undefined inside of component filter
up vote
0
down vote
favorite
I have filter on my component
filters: {
formatStatus (value) {
let status = {
active: {
text: this.$t('general.successful'),
class: 'secondary--text'
},
processing: {
text: this.$t('general.processing'),
class: 'tertiary--text'
},
waiting: {
text: this.$t('general.pending'),
class: 'tertiary--text'
}
}
return status[value]
}
}
but i got an error
TypeError: Cannot read property '$t' of undefined
but on methods,
$t is working fine.
vue.js vuejs2 nuxt
add a comment |
up vote
0
down vote
favorite
I have filter on my component
filters: {
formatStatus (value) {
let status = {
active: {
text: this.$t('general.successful'),
class: 'secondary--text'
},
processing: {
text: this.$t('general.processing'),
class: 'tertiary--text'
},
waiting: {
text: this.$t('general.pending'),
class: 'tertiary--text'
}
}
return status[value]
}
}
but i got an error
TypeError: Cannot read property '$t' of undefined
but on methods,
$t is working fine.
vue.js vuejs2 nuxt
Insidefilters:
this = undefined, not your vue instance. And "filter should be pure - no side effects, just data in and data out".. you can use methods or computed property instead.
– Sajib Khan
Nov 7 at 10:37
I see, so it should be standalone. Thanks!
– Mark
Nov 7 at 10:45
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have filter on my component
filters: {
formatStatus (value) {
let status = {
active: {
text: this.$t('general.successful'),
class: 'secondary--text'
},
processing: {
text: this.$t('general.processing'),
class: 'tertiary--text'
},
waiting: {
text: this.$t('general.pending'),
class: 'tertiary--text'
}
}
return status[value]
}
}
but i got an error
TypeError: Cannot read property '$t' of undefined
but on methods,
$t is working fine.
vue.js vuejs2 nuxt
I have filter on my component
filters: {
formatStatus (value) {
let status = {
active: {
text: this.$t('general.successful'),
class: 'secondary--text'
},
processing: {
text: this.$t('general.processing'),
class: 'tertiary--text'
},
waiting: {
text: this.$t('general.pending'),
class: 'tertiary--text'
}
}
return status[value]
}
}
but i got an error
TypeError: Cannot read property '$t' of undefined
but on methods,
$t is working fine.
vue.js vuejs2 nuxt
vue.js vuejs2 nuxt
asked Nov 7 at 10:26
Mark
559
559
Insidefilters:
this = undefined, not your vue instance. And "filter should be pure - no side effects, just data in and data out".. you can use methods or computed property instead.
– Sajib Khan
Nov 7 at 10:37
I see, so it should be standalone. Thanks!
– Mark
Nov 7 at 10:45
add a comment |
Insidefilters:
this = undefined, not your vue instance. And "filter should be pure - no side effects, just data in and data out".. you can use methods or computed property instead.
– Sajib Khan
Nov 7 at 10:37
I see, so it should be standalone. Thanks!
– Mark
Nov 7 at 10:45
Inside
filters:
this = undefined, not your vue instance. And "filter should be pure - no side effects, just data in and data out".. you can use methods or computed property instead.– Sajib Khan
Nov 7 at 10:37
Inside
filters:
this = undefined, not your vue instance. And "filter should be pure - no side effects, just data in and data out".. you can use methods or computed property instead.– Sajib Khan
Nov 7 at 10:37
I see, so it should be standalone. Thanks!
– Mark
Nov 7 at 10:45
I see, so it should be standalone. Thanks!
– Mark
Nov 7 at 10:45
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53187597%2ft-is-undefined-inside-of-component-filter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Inside
filters:
this = undefined, not your vue instance. And "filter should be pure - no side effects, just data in and data out".. you can use methods or computed property instead.– Sajib Khan
Nov 7 at 10:37
I see, so it should be standalone. Thanks!
– Mark
Nov 7 at 10:45