Answer the question
In order to leave comments, you need to log in
Which vue.js lifecycle hook should I hang another component's event handling on?
Good day!
There is a search field with a dropdown list that appears as a result of field autocompletion, this works.
Task: when clicking on any free space, that is, on the parent component, close (hide) the list, that is, the child component.
Events are processed through a common bus.
When clicking on a free space, the event is correctly generated.
In parent component:
methods: {
searchClose: function() {
console.log('Клик') // Это срабатывает
bus.$emit("searchclose"); // Это тоже срабатывает
}
}
created() {
bus.$on('searchlose', function() {
this.searchList = false;
})
},
Answer the question
In order to leave comments, you need to log in
You have a typo in your code, but in general, in this case, the "child component" itself usually contains an absolutely positioned full-screen watermark, which is shown when necessary (for example:
position: absolute;
top: 0;
left: 0;
z-index: 1000;
width: 100%;
height: 100%;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question