我有两个search components
,我想将第一个组件的搜索与另一个组件上的搜索过滤器连接起来。我如何将这两者连接起来?
in the first component
<input type="text" class="searchTerm" placeholder="What are you looking for?" v-model="str" aria-label="Search" />
<button type="submit" class="searchButton" @click="$router.push('/internships')" @click.prevent="performSearch()">
<i class="fa fa-search"></i>
</button>
In the second component
<form @submit.prevent="performSearch" class="search p-2 bg-2">
<input type="text" class="searchTerm" v-model="str" placeholder="Search?"/>
<button class="searchButton" type="submit">
<i class="fa fa-search"></i>
</button>
发布于 2021-04-12 07:05:46
您可以传递到您的路由查询,然后从URL获取它们。
$router.push(path: 'internships', query: {searchText: 'str in your case'})
// Then for get the query from url:
this.$route.query.searchText
请阅读本文以了解更多信息。https://router.vuejs.org/guide/essentials/navigation.html
注意:用户可以在步骤之间编辑url。
https://stackoverflow.com/questions/67052951
复制相似问题