vuejs2 - Algolia Instantsearch (Vuejs) - Place searchbox outside (in a different component)
问题描述
I'm building a Single Page Application using, Vue, Vue-router and Vuex. I've tried to implement Algolia Instantsearch vuejs, but I'm having some issues. Since my app is using a lot of nested components, I'm having a hard time figuring out how to structure this one.
This is the basic structure: - App - Header (this is where the search input is placed) - Content - Search (this is where the refinements and results are shown) - Footer
I've read the documentation, but I might have missed something. Let's say the user is on the homepage, when starting typing into the searchinput in the Header component. I then use vue-router to go to /search, but this doesn't seem to work?
I don't know how to do this? As from what I can understand, the documentation only show you how to sync with vue-router and now how to handle my scenario.
I believe this is a fairly common use case for instantsearch, but I couldn't find anything searching through Google. Maybe because, I don't know how to describe the issue.
I hope you can help.
Thanks!
解决方案
如果您使用最新版本的 vue-instantsearch,您可以按照https://www.algolia.com/doc/api-reference/widgets/configure/vue/ais-configure
的描述使用。
<ais-instant-search :index-name="indexName" :search-client="searchClient">
<ais-configure :query="query" />
<ais-hits>
<div slot="item" slot-scope="{ item }">
<h2>{{ item }}</h2>
</div>
</ais-hits>
</ais-instant-search>
推荐阅读
- c - ARM 处理器如何区分负数和正数?
- javascript - 如何设置滑块轮播的最小高度等于图像的变化高度?
- javascript - Laravel - 从单行中提取多列数据并用于下拉
- excel - 在特定列中查找最后使用的单元格并用范围包围
- docker - kafka-connect-jdbc 源连接器OOM
- java - 我的表格中有 18 行,表格已添加到面板中,但我想显示最多 10 行,其余的应该是可滚动的
- cas - CAS 5 版本的 deployerConfigContext
- uwp - 使用 ReactiveUI 包的通用 Windows 应用程序无法在发布模式下构建
- javascript - 如何从多个子组件中获取表单值?
- reactjs - Javascript React:推送到 useState 中的数组