简体   繁体   English

有没有办法在反应项目中使用 min.js 文件? 这是一个好习惯吗?

[英]Is there a way to use min.js file into a react project? Is it a good practice?

I am new to react.我是新来的反应。 I have a min.js file that has a functionality that I want to use in my react project.我有一个 min.js 文件,该文件具有我想在我的 React 项目中使用的功能。 However, I haven't found a way to use it.但是,我还没有找到使用它的方法。 I don't know where to place that file, how to import it in my react project and finally use a function in that file.我不知道将该文件放在哪里,如何将它导入到我的 React 项目中并最终使用该文件中的函数。 Apparently, the creator has not made it available via npm yet.显然,创建者还没有通过 npm 提供它。 Also, is it a good practice to use the file in the react project?另外,在反应项目中使用该文件是一个好习惯吗?

Inside your react project在你的反应项目中

  • public\\index.html公共\\index.html
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <main id="container"></main>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.8.6/umd/react.production.min.js"></script>

Add the used min.js like above would be fine.像上面一样添加使用过的min.js就可以了。


It will be requested when you start your page, like the below example.当你启动你的页面时,它会被请求,就像下面的例子。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM