繁体   English   中英

使用带有反应的 jquery 插件时导入错误

[英]error with imports when using jquery plugin with react

我正在尝试使用 jquery.infinitedrag 在反应中创建一个组件。 我的代码在这里:

//Grid.js

import React from 'react'
import './jquery/jquery.min.js'
import './jquery/jquery-ui.min.js'
import './jquery/jquery-ui.min.css'
import './jquery/jquery.infinitedrag.js'

export default class Grid extends React.Component{

    componentDidMount() {
        $.infinitedrag("wall")
    }

    render() {
        return(
            <div id="wall"/>
        )
    }
}

这应该通过在反应渲染时制作一个 div(由 id 标识)然后在组件安装后填充无限网格来工作。 问题是,出于某种原因,jquery.infinitedrag 变得混乱了。 这是错误:

Failed to compile.

./src/jquery/jquery.infinitedrag.js
  Line 108:4:  Expected an assignment or function call and instead saw an expression  no-unused-expressions
  Line 277:4:  'jQuery' is not defined                                                no-undef

我的文件结构如下所示:

src
  -jquery
    -jquery.min.js
    -jquery-ui.min.js
    -jquery-ui.min.css
    -jquery.infinitedrag.min.js
  -Grid.js
  -misc other components and stuff

我是 javascript 的新手,所以这可能有些愚蠢。

npm install jquerynpm update以消除第二个错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM