在 Ionic 中哪里包含 js 库? [英] Where to include js libraries in Ionic?

查看:18
本文介绍了在 Ionic 中哪里包含 js 库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

感谢您的时间!我正在努力让任何脚本在 Ionic 框架的 sidemenu starter 模板中运行.我已经把它们放在任何地方(除了它们应该在的地方,很明显)但没有用.我试过在 ionic 之前加载它们,也尝试过使用较低版本的 jquery.我已经使用 jquery 构建了一个不错的移动网站,我已经通过 phonegap 推送了它并且它运行良好,但我想使用 Ionic 作为个人挑战.但是,我似乎无法获得我用来工作的任何脚本.

thanks for your time! I am battling to get any scripts running in the Ionic framework's sidemenu starter template. I have placed them everywhere (except where they're supposed to be, clearly) but to no avail. I have tried loading them before ionic and also using a lower version of jquery. I have built a decent mobile site with jquery that I've pushed through phonegap and it works perfectly but I would like to use Ionic as a personal challenge. However, I can't seem to get any of the scripts I'm using to work.

我是否将它们包含在主索引文件中?如果是,它们是否会在每个模板实例化时加载?或者我必须将它们包含在每个模板中?如果您可以具体说明我应该将它们放在文件夹中的哪个位置(如果确实有一个特定的位置)以及我应该在哪里调用脚本.

Do I include them in the main index file and if so, do they get loaded when each template instantiates? Or must I include them in each of the templates? If you could please be quite specific as to where in the folders I should place them (if indeed there is a specific place) and also where I should call the scripts.

我使用这个 yeoman 生成器安装了 ionic https://github.com/diegonetto/generator-ionic 如果有帮助的话.

I installed ionic using this yeoman generator https://github.com/diegonetto/generator-ionic if that helps.

如果我的注释足够清楚,请评论,我会进一步详细说明.

If I have note been clear enough please comment and I will elaborate further.

感谢您的耐心等待 - J

Thank you for your patience - J

推荐答案

我会在cordova 的脚本标记之前或之后添加任何脚本,例如jquery.它位于运行创建的 yeoman 生成器的项目的 app/ 目录中的 index.html 中.

I would add any scripts such as jquery either just before or just after the script tag for cordova. This is in index.html located within the app/ directory of the project that running the yeoman generator created.

<!-- Place scripts such as JQuery here -->

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

    <script src="scripts/config.js"></script>
    <script src="scripts/app.js"></script>
    <script src="scripts/controllers.js"></script>

在此处放置脚本后,它们将在应用程序运行时被调用,并且诸如 jquery 之类的库将在整个应用程序中全局可用.我希望这会有所帮助.

Once you have placed the scripts here they will get called when the app runs, and libraries such as jquery will be available globally throughout the app. I hope this helps.

这篇关于在 Ionic 中哪里包含 js 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆