我正在为React图进行演示,我正在使用React Webpack,但是控制台出现错误,
ERROR in ./node_modules/storm-react-diagrams/dist/style.min.css 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
在这里,我已经添加了它的整个脚本,有人可以看一下我的代码并帮助我解决此问题吗?
App.js
import React from 'react';
import $ from "jquery";
import * as SRD from "storm-react-diagrams"
require("storm-react-diagrams/dist/style.min.css")
class App extends React.Component {
componentDidMount() {
// 1) setup the diagram engine
var engine = new SRD.DiagramEngine();
engine.installDefaultFactories();
// 2) setup the diagram model
var model = new SRD.DiagramModel();
// 3) create a default node
var node1 = new SRD.DefaultNodeModel("Node 1", "rgb(0,192,255)");
let port1 = node1.addOutPort("Out");
node1.setPosition(100, 100);
// 4) create another default node
var node2 = new SRD.DefaultNodeModel("Node 2", "rgb(192,255,0)");
let port2 = node2.addInPort("In");
node2.setPosition(400, 100);
// 5) link the ports
let link1 = port1.link(port2);
// 6) add the models to the root graph
model.addAll(node1, node2, link1);
// 7) load model into engine
engine.setDiagramModel(model);
}
render() {
return <SRD.DiagramWidget diagramEngine={engine} />
}
}
export default App;
答案 0 :(得分:1)
您必须将css加载程序与webpack一起使用,因为您正试图在js文件中导入css文件。