简体   繁体   English

如何在离子应用程序中包含javascript第三方库?

[英]How to include javascript third party library in ionic app?

I am sorry to ask this silly question. 我很抱歉地问这个愚蠢的问题。 I am trying to use pathfinding.js ( https://github.com/qiao/PathFinding.js/ ) in ionic for my navigation.html page (a partial file located in the www/templates/ directory) but it's not working with partials files except with index.html root file only. 我试图在我的navigation.html页面(位于www / templates /目录中的部分文件)中使用离子的pathfinding.js( https://github.com/qiao/PathFinding.js/ ),但它不能用于部分文件除了index.html根文件外。 However, it gives me error if I use it in the index.html root file, maybe because it needs to draw a svg in the navigation.html page, but it could not find the navigation.html page since it is in the index.html (dependency with the navigation.html) 但是,如果我在index.html根文件中使用它,它会给我错误,可能是因为它需要在navigation.html页面中绘制svg,但由于它在索引中,因此无法找到navigation.html页面。 html(与navigation.html的相关性)

I am thinking to use bower, but can bower solve this problem? 我想用凉亭,但是能否解决这个问题呢?

In index file add the script tag to add scripts. 在索引文件中添加脚本标记以添加脚本。

<script src="./templates/PathFinding.js/" >` <script src="./templates/PathFinding.js/" >`

It will get loaded. 它会被加载。

However, if you use Bower.. Bower will only download the files to src folder .. then you need to manually add script tags for script into the index.html . 但是,如果你使用Bower .. Bower只会将文件下载到src文件夹..那么你需要手动将脚本的脚本标签添加到index.html

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

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