简体   繁体   English

Meteor React 外部 JS 文件

[英]Meteor React External JS Files

I have an HTML template which is bought from Themeforest , index.html of this template has js files included in the following order:我有一个从Themeforest购买的 HTML 模板,该模板的 index.html 包含按以下顺序包含的 js 文件:

<!-- Scripts -->
    <script src="js/vendor/jquery-2.1.0.min.js"></script>
    <script src="js/helper.js"></script>
    <script src="js/vendor/HeadsUp.js"></script>
    <script src="js/vendor/chart.min.js"></script>
    <script src="js/vendor/jquery.mixitup.min.js"></script>
    <script src="js/vendor/jquery.swipebox.min.js"></script>
    <script src="js/vendor/masonry.min.js"></script>
    <script src="js/vendor/swiper.min.js"></script>
    <script src="js/vendor/materialize.min.js"></script>
    <script src="js/main.js"></script>
  </body>

How and where should I include these external js files in my Meteor React application?我应该如何以及在哪里在我的 Meteor React 应用程序中包含这些外部 js 文件?

As mentioned in this meteor documentation , you can create a compatibility folder from on client .正如这个meteor 文档中提到的,您可以从client创建一个compatibility文件夹。

This folder is for compatibility with JavaScript libraries that rely on variables declared with var at the top level being exported as globals.此文件夹用于与 JavaScript 库兼容,这些库依赖于在顶层使用 var 声明的变量作为全局变量导出。 Files in this directory are executed without being wrapped in a new variable scope.此目录中的文件将在不包含在新变量作用域中的情况下执行。 These files are executed before other client-side JavaScript files.这些文件在其他客户端 JavaScript 文件之前执行。

It is recommended to use npm for 3rd party JavaScript libraries and use import to control when files are loaded.建议将 npm 用于 3rd 方 JavaScript 库,并使用 import 来控制何时加载文件。

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

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