In an html page you can include a javascript file by <script src="path"></script>
How do you get variables from an external path like this in react, if the path is, for example: <script src="https://unpkg.com/flux-sdk-helpers@0.1/dist/flux-sdk-helpers.min.js"></script>
Thanks for all your help
Scripts loaded in that fashion normally install themselves as global variables and/or properties of some other global library.
According to the docs , flux-sdk-helpers installs itself as a global variable FluxHelpers
when you install it this way.
This means your React code can access it as either FluxHelpers
or window.FluxHelpers
.
你可以在你的index.html文件中链接它只是要小心你在做什么时调用的东西,以免在不同的地方使用名称
if you are using react, then you probably should also learn about webpack.
if you will use webpack, then you can import { method} from "package"
most scripts you got from NPM (node package manager) very easily.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.