nuxtjs中的owl-carousel实现问题

问题描述 投票:0回答:1

我在使用nuxtjs实现v-owl-carousel时遇到问题。

当我尝试:

import carousel from 'v-owl-carousel'

出现错误消息

文件未定义

我按照本页https://github.com/93gaurav93/v-owl-carousel的要求进行了配置建议,但没有任何作用......

有人可以帮帮我吗?有人可以给我一个轨道吗?

配置空项目

{
  "name": "nuxtjs_test_owl_carousel",
  "version": "1.0.0",
  "description": "My gnarly Nuxt.js project",
  "author": "",
  "private": true,
  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "cross-env": "^5.2.0",
    "nuxt": "^2.4.0",
    "v-owl-carousel": "^1.0.8"
  },
  "devDependencies": {
    "nodemon": "^1.18.9"
  }
}
nuxt.js
1个回答
0
投票

https://nuxtjs.org/faq/window-document-undefined/

这是由于服务器端呈现。如果需要指定仅在客户端导入资源,则需要使用process.client变量。

例如,在.vue文件中:

if(process.client){require('external_library')}

© www.soinside.com 2019 - 2024. All rights reserved.