Answer the question
In order to leave comments, you need to log in
How to subscribe to the event of a child component?
<script>
export default {
name: 'TableOfContent',
methods: {
itemClick(theguid)
{
console.log(theguid); // выводит на консоль
this.$emit('newchapter', 777) // передаем 777 для теста
}
}
}
</script>
<template>
<toc :newchapter="foo(3)">
<div class="Book">
{{msg}}
</div>
</toc>
</template>
<script>
import toc from './TableOfContent.vue'
export default {
props: ['theguid'],
name: 'mybook',
data () {
return {
msg: 'my main book'
}
},
methods:
{
foo(id)
{
console.log("GUID is: ", id);
}
},
components: {toc}
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question