mixin method is undefined in created hook of component
up vote
0
down vote
favorite
<template>
<section>
<a href="#toper" class="cd-top" v-on:click="getTemplates()">Top</a>
</section>
</template>
<script>
import api from '../../server/api.ts';
export default {
name: 'Questions',
mixins: [api],
data() {
return {
templates : getTemplates(),
};
},
created() {
// **[Vue warn]: Error in created hook: "ReferenceError: getTemplates is not defined"**
this.templates = getTemplates();
},
};
</script>
getTemplates function is working fine if i click on link but getting error in all life hooks of Vue js component.
Thanks for help in advance !
vue.js vuejs2 mixins
add a comment |
up vote
0
down vote
favorite
<template>
<section>
<a href="#toper" class="cd-top" v-on:click="getTemplates()">Top</a>
</section>
</template>
<script>
import api from '../../server/api.ts';
export default {
name: 'Questions',
mixins: [api],
data() {
return {
templates : getTemplates(),
};
},
created() {
// **[Vue warn]: Error in created hook: "ReferenceError: getTemplates is not defined"**
this.templates = getTemplates();
},
};
</script>
getTemplates function is working fine if i click on link but getting error in all life hooks of Vue js component.
Thanks for help in advance !
vue.js vuejs2 mixins
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
<template>
<section>
<a href="#toper" class="cd-top" v-on:click="getTemplates()">Top</a>
</section>
</template>
<script>
import api from '../../server/api.ts';
export default {
name: 'Questions',
mixins: [api],
data() {
return {
templates : getTemplates(),
};
},
created() {
// **[Vue warn]: Error in created hook: "ReferenceError: getTemplates is not defined"**
this.templates = getTemplates();
},
};
</script>
getTemplates function is working fine if i click on link but getting error in all life hooks of Vue js component.
Thanks for help in advance !
vue.js vuejs2 mixins
<template>
<section>
<a href="#toper" class="cd-top" v-on:click="getTemplates()">Top</a>
</section>
</template>
<script>
import api from '../../server/api.ts';
export default {
name: 'Questions',
mixins: [api],
data() {
return {
templates : getTemplates(),
};
},
created() {
// **[Vue warn]: Error in created hook: "ReferenceError: getTemplates is not defined"**
this.templates = getTemplates();
},
};
</script>
getTemplates function is working fine if i click on link but getting error in all life hooks of Vue js component.
Thanks for help in advance !
vue.js vuejs2 mixins
vue.js vuejs2 mixins
asked 2 days ago


Muhammad Atif
859414
859414
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
You forgot this
for the function. Loading mixins has the same effect as if the content in it would be in your actual component. You need to call the methods the same way as you would call a local function. Always with this
.
So change it to:
created() {
this.templates = this.getTemplates();
},
Thanks :) this works
– Muhammad Atif
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You forgot this
for the function. Loading mixins has the same effect as if the content in it would be in your actual component. You need to call the methods the same way as you would call a local function. Always with this
.
So change it to:
created() {
this.templates = this.getTemplates();
},
Thanks :) this works
– Muhammad Atif
2 days ago
add a comment |
up vote
1
down vote
accepted
You forgot this
for the function. Loading mixins has the same effect as if the content in it would be in your actual component. You need to call the methods the same way as you would call a local function. Always with this
.
So change it to:
created() {
this.templates = this.getTemplates();
},
Thanks :) this works
– Muhammad Atif
2 days ago
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You forgot this
for the function. Loading mixins has the same effect as if the content in it would be in your actual component. You need to call the methods the same way as you would call a local function. Always with this
.
So change it to:
created() {
this.templates = this.getTemplates();
},
You forgot this
for the function. Loading mixins has the same effect as if the content in it would be in your actual component. You need to call the methods the same way as you would call a local function. Always with this
.
So change it to:
created() {
this.templates = this.getTemplates();
},
answered 2 days ago
Matthias S
1,3161916
1,3161916
Thanks :) this works
– Muhammad Atif
2 days ago
add a comment |
Thanks :) this works
– Muhammad Atif
2 days ago
Thanks :) this works
– Muhammad Atif
2 days ago
Thanks :) this works
– Muhammad Atif
2 days ago
add a comment |
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%2f53373666%2fmixin-method-is-undefined-in-created-hook-of-component%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