Just starting out with Vue and frontend development.
I'm attempting to create a universal navigation bar in Vue Router using bootstrap vue, complete with a search bar feature.
However, because I have placed my navigation bar in App.vue, I am encountering difficulties passing the search function to specific routes.
Here is a snippet of what I currently have in my App.vue file:
<div id="app">
<b-navbar toggleable="lg" variant="light" type="light" class="justify-content-between">
<b-navbar-brand><router-link to="/">Brand</router-link></b-navbar-brand>
<b-collapse class="nav-collapse" is-nav>
<b-nav-item><router-link to="/about">Route 1</router-link></b-nav-item>
</b-collapse>
<b-navbar-nav class="ml-auto">
<b-nav-form>
<b-form-input class="form-control mr-sm-2" v-model="search_term" placeholder="Search..."></b-form-input>
<b-button variant="outline-success my-2 my-sm-2" type="submit" v-on:click="getSearch(search_term)">Search</b-button>
</b-nav-form>
</b-navbar-nav>
</b-navbar>
<router-view/>
</div>
The router functions are within their own class.
The search functionality under b-nav-form was originally implemented on a specific page where the functions exist. Placing it within individual pages would require re-rendering each time the user navigates. Therefore, I opted to include it in the App.vue page for permanent rendering.
Is there a way to pass the search term to its respective function on its designated page while keeping the navbar universal? Is this feasible, or would it be simpler to keep the navbar on its own page?