首页 > 解决方案 > 如何在反应浏览器中导入 unpkg 组件

问题描述

我通过从 unpkg 导入直接在浏览器中使用 React。但是当我包含组件时react-pagination-jsPagination在整个范围的其余部分仍然未定义。

<!-- Note: when deploying, replace "development.js" with "production.min.js". -->
<script src="https://unpkg.com/react@16/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js" crossorigin></script>

<!-- react-js-pagination -->
<script src="https://unpkg.com/react-pagination-js@2.0.0/dist/index.umd.js"></script>

<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel" src="{% static 'js/practice/ChallengeList.js' %}"></script>

<script type="text/babel">
  const e = React.createElement;
  const el = document.querySelector('#challenges-component');
  ReactDOM.render(e(ChallengeList), el);
</script>

如何Pagination在我的ChallengeList组件中使用?

标签: reactjsunpkg

解决方案


推荐阅读