Reputation: 1102
<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 !
Upvotes: 0
Views: 2229
Reputation: 3553
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();
},
Upvotes: 1