如何使用简单的脚本标签将React-Redux(用于Redux的反应绑定)JavaScript库加载到网页上?
我已经看到了从node_modules将React-Redux作为NPM模块加载的示例,但是在我的情况下,这不是一个选择。
我在追求这样的东西:
<!-- load React-Redux with simple script tag -->
<script src="....."></script>
<script>
// Cannot use npm modules from node_modules, so cannot use
// import { Provider } from "react-redux";
// Assign Provider and connect variable if needed from
// some symbol defined in the .js file that was loaded
// by the script tag
var Provider = ....;
var connect = ....;
// Load my own hypothetical ES6 modules (not relevant to this question)
import store from "./store";
import App from "./App";
const rootElement = document.getElementById("root");
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
rootElement
);
</script>
答案 0 :(得分:1)
您所需要的全部都提到了right here。
<script src="https://unpkg.com/react-redux@5.0.7/dist/react-redux.min.js"></script>
然后,您基本上可以使用window.ReactRedux
。