How to handle search with $emit value?
See original GitHub issueI have search input field in header component. I’m getting emitted value but it’s doesn’t filter content. How do i pass $fetch with $emit from header component or what is the right way?
Index.vue
import Header from '@/components/layout/header';
export default {
components: {
Header
},
data() {
return {
posts: [],
q: ''
}
},
async fetch() {
this.posts = await this.$content('posts')
.search(this.q)
.fetch()
}
}
Header.vue
<template>
<div>
<input type="search" placeholder="Type your search" v-model="q" @input="$emit('q', $event)">
</div>
</template>
<script>
export default {
props: [ 'q' ]
}
</script>
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to Emit Data in Vue: Beyond the Vue.js Documentation
In this blog, we learn how to emit events from child components in Vue, as well as how to emit from nested child...
Read more >Emit Observable value and handle it in component
What I want is to emit value from login() method in AuthService to handle value in NavbarComponent , however value of appUser$ is...
Read more >Component Events | Vue.js
A component can emit custom events directly in template expressions (e.g. in a v-on ... It's sometimes useful to emit a specific value...
Read more >What you should know about Vue v-model - LearnVue
One way to ensure that our value is handled as a Number is to use the ... When we use a custom model...
Read more >Form Input | Components - BootstrapVue
update. value - Value of input, after any formatting. Not emitted if the value does not change. Emitted to update the v-model ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Then you need to add a method onSearch to update q and call fetch() again
I think that you can call
this.$fetch()
instead ofthis.$content('posts')..