【问题标题】:TypeError: Cannot read property 'fn' of undefined in react jsTypeError:无法读取反应js中未定义的属性'fn'
【发布时间】:2020-06-03 05:51:01
【问题描述】:

我已经安装了 owl carousel(npm install react-owl-carousel2)。运行代码时显示以下错误。

TypeError: Cannot read property 'fn' of undefined
    eval
    ././src/owl.carousel.js?:1667:4
    eval
    ././src/owl.carousel.js?:1701:3
    (anonymous function)
    C:/xampp/htdocs/new-react/node_modules/react-owl-carousel2/lib/OwlCarousel.js:63
      60 | /* 1 */
      61 | /***/ function(module, exports) {
      62 | 
     63 |   eval("'

对于未定义错误的“fn”我需要做什么?

【问题讨论】:

  • 你能分享你使用轮播的代码吗?
  • 将 jquery 添加到您的 index.html,或在配置文件中声明

标签: javascript reactjs owl-carousel


【解决方案1】:

【讨论】:

  • 感谢您的回复。我需要在哪里输入此代码。在哪个文件中
  • 你导入owl carousel的文件
【解决方案2】:

包括这是插件数组 路径:Project\node_modules\react-scripts\config\webpack.config.js

     new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery',
      }),

【讨论】:

    猜你喜欢
    • 2021-02-01
    • 2020-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-17
    • 1970-01-01
    • 2022-09-27
    相关资源
    最近更新 更多