0

节点版本:v10.14.1 NPM 版本:6.4.1:操作系统:Windows

描述: 我在我的 vuejs 项目中集成了 algolia,效果很好。现在我正在将此模块从版本 1.7.0 升级到 2.0.0。在升级包时,它显示控制台错误并且屏幕上没有显示任何内容。我也尝试通过包含所需的包来解决它,但没有得到结果。以下是控制台错误:

[Vue warn]:Unknown custom element: <ais-index> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
[Vue warn]: Unknown custom element: <ais-input> - did you register the component correctly? For recursive components, make sure to provide the "name" option
[Vue warn]: Error in nextTick: "TypeError: It looks like you forgot to wrap your Algolia search component "<ais-refinement-list>" inside of an "<ais-instant-search>" component."
TypeError: It looks like you forgot to wrap your Algolia search component "<ais-refinement-list>" inside of an "<ais-instant-search>" component.

这是我的代码:

<template>
  <div id="app">
    <p>{msg}</p>
    <div id="app">
      <ais-index app-id="latency" api-key="6be0576ff61c053d5f9a3225e2a90f76" index-name="ikea">
        <ais-search-box placeholder="Search for a product..."></ais-search-box>
        <ais-results>
          <template scope="{ result }">
            <div class="search-result">
              <img class="result__image img-responsive" :src="result.image">

              <div class="result__info">
                <h2 class="result__name">
                  <ais-highlight :result="result" attribute-name="name"/>
                </h2>
                <div class="result__type">
                  <ais-highlight :result="result" attribute-name="type"/>
                </div>
                <div class="result__rating">
                  <template v-for="n in 5">
                    <span v-if="n <= result.rating" class="result__star"></span>
                    <span v-else class="result__star--empty"></span>
                  </template>
                </div>
                <div class="result__price">${{result.price}}</div>
              </div>
            </div>
          </template>
        </ais-results>
        <ais-pagination v-bind:class-names="{'ais-pagination': 'pagination'}"></ais-pagination>
      </ais-index>
    </div>
  </div>
</template>
<script>
//main.js 
import 'babel-polyfill'
import Vue from 'vue'
import Vuetify from 'vuetify'
import InstantSearch from 'vue-instantsearch'

//router 
import router from './router'
Vue.use(InstantSearch)

Vue.config.productionTip = false

new Vue({
    store,
    router,
    i18n,
    render: h => h(App)
}).$mount('#app')

需要进行哪些更改才能使其正常工作?如果有人需要更多信息,请告诉我。谢谢!

4

1 回答 1

1

根据您的错误消息:

TypeError: It looks like you forgot to wrap your Algolia search component "<ais-refinement-list>" inside of an "<ais-instant-search>" component.

看起来<ais-instant-search>可能需要新的vue-instantsearchAPI 主要版本。

所以,用包装组件,<ais-instant-search>看看它是怎么回事:)

于 2019-03-22T11:06:57.633 回答