在react中导入draw2d会导致jquery引用错误



一旦我将import draw2d from "draw2d"添加到导入中,我就会得到ReferenceError: jQuery is not defined

我试着安装并添加jquery,但仍然出现了同样的错误。。。

import React, {Component} from "react";
import jQuery from "jquery";
import draw2d from "draw2d";

创建一个具有任何名称的文件,例如import-jquery.js

import-jquery.js

import jquery from "jquery";
window.$ = window.jQuery = jquery;

应用程序.js

import "import-jquery";
import "jquery-ui-bundle"; // you also need this
import "jquery-ui-bundle/jquery-ui.css";
import draw2d from "draw2d";

编辑:

别忘了…

npm install jquery
npm install jquery-ui-bundle

最新更新