使用unpkg时require未定义错误

时间:2019-03-15 13:59:39

标签: javascript html node.js reactjs unpkg

我正在尝试使用react-tree-graph使用npm软件包unpkg,但出现错误

  

require is not defined error。

我也尝试过添加require npm软件包,但是没有用

const {
  Button
} = Reactstrap;
//const {Tree} = "react-tree-graph";
import Tree from "https://unpkg.com/react-tree-graph@4.0.0/dist/index.js";
import require from "https://unpkg.com/requirejs@2.3.6/bin/r.js";



let data = {
  name: 'Parent',
  children: [{
    name: 'Child One'
  }, {
    name: 'Child Two'
  }]
};

// Render a Reactstrap Button element onto root
ReactDOM.render( <
  Tree data = {
    data
  }
  height = {
    400
  }
  width = {
    400
  }
  />,
  document.getElementById('root')
);
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>repl.it</title>
  <link href="style.css" rel="stylesheet" type="text/css" />
  <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-tree-graph@4.0.0/dist/index.js"></script>
  <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
  <script src="https://unpkg.com/requirejs@2.3.6/bin/r.js"></script>

  <script src="https://unpkg.com/react-transition-group@2.2.1/dist/react-transition-group.min.js" charset="utf-8"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/reactstrap/4.8.0/reactstrap.min.js" charset="utf-8"></script>

</head>

<body>
  <div id="root"></div>
  <script src="script.js" type="text/babel"></script>

</body>

</html>

0 个答案:

没有答案