I'm pretty new to Vuejs and I'd just like to call a methode from my Vue instance but it seems like this is a porblem and I don't know why.
Vue instance:
var monster = new Vue({
el: '#monsterlist',
data: {
monsters: undefined
},
created: async function (){
this.monsters = await this.loadMonster()
},
methods: {
loadMonster: async function () {
//stuff
},
deleteMonster: async function(id){
//stuff
}
}
})
Component:
Vue.component('monster', {
template: '<div class="content overlayable"> <div class="overlay" v-if="monster.deleting"><div class="lds-ripple"><div></div><div></div></div></div> <div><h1>{{monster.name}}</h1> <div class="static"> <div class="des"><img v-if="monster.image != undefined && monster.image != ``" :src="monster.image"> <a v-else>No monster image</a></div> <button class="denyBtn" v-on:click="deleteMonster(monster._id)">Delete</button> </div></div> </div>',
props: ['monster']
})
I'd like to call the deleteMonster() methode with the id of my monster with a button declared in the component.
Here is the error I'm getting:
vue@2:6 ReferenceError: deleteMonster is not defined
at click (eval at Ya (vue@2:6), <anonymous>:3:451)
at He (vue@2:6)
at HTMLButtonElement.n (vue@2:6)
at HTMLButtonElement.Yr.o._wrapper (vue@2:6)