Nuxt未注册v-touch组件

时间:2018-08-21 11:37:18

标签: javascript vue.js nuxt.js

我创建了一个非Nuxt Vue目录,以使用v-touch进行播放。我在该目录中使用了v-touch组件。

我现在正在尝试将工作代码移植到使用Nuxt的Vue设置中,但是我经常遇到以下错误:Unknown custom element: <v-touch> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

我在global.js中有一个/plugins/文件,它可以:

import Vue from 'vue'

if (process.browser) {
  window.onNuxtReady(() => {
    const VueTouch = require('vue-touch')
    Vue.use(VueTouch)
  })
}

在我的nuxt.config.js文件中,我有:vendor: ['vue-touch']plugins: [{ src: '~plugins/global', ssr: false }]

然后在我的`.Vue中。文件,这是我要呈现的HTML模板:

<template>
  <no-ssr>
    <div class="main">
      <div id="slider" class="slider" >
        <v-touch @pan="mouseMoving" @panend="stopDrag" @swipe="startDrag">
          <div class="slider-cards" :style="`transform: translate3d(${cardsX}px,0,0)`">
            <div v-for="num in 3" class="slider-card">
              <Card />
            </div>
          </div>
        </v-touch>
      </div>
    </div>
  </no-ssr>
</template>

我尝试了各种组合,包括以不同形式(包括导入,需求等)包含依赖项,但是我不知道如何使此依赖项按应有的方式运行。我会感谢您的帮助!

0 个答案:

没有答案