如何使用CDN链接使用Reactstrap



我正在将React与CDN链接一起使用,在经历了一点头疼之后,我意识到我需要了解为每个库配置的全局变量是什么才能使用它们。

例如,在React Redux中,而不是:

import {connect} from 'react-redux'

这将导致:

Uncaught TypeError: Failed to resolve module specifier "react-redux". Relative references must start with either "/", "./", or "../".

我需要做:

export defaultReactRedux.connect(mapStateToProps, mapDispatchToProps)(Component)

就像我需要处理React.Component一样。

这很有道理。

现在我正在搜索为Reactstrap定义的全局变量。不幸的是,使用CDN链接的演示链接已断开(我已经打开了一个问题(。

我在网上搜索了一下Reactstrap文档,但什么也找不到。

我猜是Reactstrap.X,但这不起作用。

我想这不是一个新的请求,但我还没有找到答案(或被问到(,所以如果你能帮我,我会很高兴。

要在CDN中使用Reactstrap,您应该导入样式表和脚本,然后对组件使用Reactstrap

示例

ReactDOM.render(<Reactstrap.Button>ReactStrap</Reactstrap.Button>, document.getElementById("react"));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.4/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.4/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/reactstrap/4.8.0/reactstrap.min.js" ></script>
<link rel="stylesheet" href= "https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<div id="react"></div>

最新更新