I have root vue component app.js:
...
const app = new Vue({
el: '#app',
...
methods: {
modalShow: function(target, id=null, message=null){
...
},
...
}
});
I have a child component like this:
<template>
<div>
<ul>
<li>
<a href="#" class="thumbnail"
title="Add photo"
@click="modalShow('modal-add-photo', product.id)"
>
<span class="fa fa-plus fa-2x"></span>
</a>
</li>
</ul>
</div>
</template>
<script>
export default {
...
methods: {
...
}
}
</script>
The modalShow
method is in the root. How can I call it from the child?
If the code above is executed now, I get the following error:
[Vue warn]: Property or method "modalShow" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.