小编Dom*_*nic的帖子

Vue-InstantSearch with Algolia & Laravel:隐藏空查询结果

我想弄清楚如何隐藏空搜索查询的索引/结果。

在我的刀片中,我有代码(根据官方文档稍作修改):

<ais-instant-search index-name="myIndex" :search-client="searchClient">
<ais-search-box placeholder="Search here"></ais-search-box>

    <ais-state-results>
      <template slot-scope="{ state: { query } }">
        <ais-hits v-if="query.length > 0">
    
            <div slot="item" slot-scope="{ item }">
                <h2>@{{ item.Title}}</h2>
                <p>@{{ item.Text}}</p>
            </div>
                                
        </ais-hits>
      </template>
    </ais-state-results> 
</ais-instant-search>
Run Code Online (Sandbox Code Playgroud)

如果我输入搜索查询,这工作正常,但在空查询中,这会在我的页面上显示以下不需要的通知(而不是之前不需要的索引):

Use this component to have a different layout based on a certain state. 
Fill in the slot, and get access to the following things on the slot-scope:
    
    results: [
      "_rawResults",
      "hits",
      "nbHits",
[..]
Run Code Online (Sandbox Code Playgroud)

如何隐藏此通知?

laravel algolia vue-instant-search

0
推荐指数
1
解决办法
826
查看次数

标签 统计

algolia ×1

laravel ×1

vue-instant-search ×1