简体   繁体   English

在适当的工作流程中将第三方JS库添加到Ionic

[英]Adding 3rd party JS libraries to Ionic within the proper workflow

I have been using jQuery Mobile for a hybrid app for the past few months and wanted to get exposure to Ionic and Angular.js so i am atempting to rebuild it. 在过去的几个月中,我一直在将jQuery Mobile用于混合应用程序,并希望接触Ionic和Angular.js,因此我希望重建它。 My JQM app relies on xml2json.js and I am completely unfamiliar with Cordova, Bower, Gulp, Node.js and several of the other tools used to build and deploy Ionic apps. 我的JQM应用程序依赖xml2json.js,而我对Cordova,Bower,Gulp,Node.js以及用于构建和部署Ionic应用程序的其他一些工具完全不熟悉。

Is there a right way, or a right place to add xml2json.js so when I build it gets pulled in automatically? 有没有正确的方法或正确的位置添加xml2json.js,以便在我构建时自动将其插入?

The answer to my question was to use Bower, however it required a bit of setup. 我的问题的答案是使用Bower,但是需要一些设置。

Install Bower (I'm on a mac, you may not need sudo) 安装Bower(我在Mac上,您可能不需要sudo)
sudo npm install -g bower

If you are behind a firewall (like at work) before installing you my need to run 如果在安装之前在防火墙后面(例如在工作中),则需要运行
npm config set strict-ssl false to fix UNABLE_TO_VERIFY_LEAF_SIGNATURE npm config set strict-ssl false修复UNABLE_TO_VERIFY_LEAF_SIGNATURE

After installing Bower again if you are behind a firewall you will need to do the following 再次安装Bower后,如果您位于防火墙后面,则需要执行以下操作
git config --global url."https://".insteadOf git:// forces bower to download modules using the HTTP address git config --global url."https://".insteadOf git://强制Bower使用HTTP地址下载模块

You will also need to edit .bowerrc in your project folder to get rid of the bower specific UNABLE_TO_VERIFY_LEAF_SIGNATURE 您还需要在项目文件夹中编辑.bowerrc,以摆脱特定于Bower的UNABLE_TO_VERIFY_LEAF_SIGNATURE

{
    "strict-ssl": false
}


After that you can run the install command 之后,您可以运行install命令
bower install xml2json --save

If you installed Ionic with npm then .bowerrc has an override to the save directory which will save to /www/lib/[plugin folder]/ 如果您使用npm安装了Ionic,则.bowerrc将覆盖保存目录,它将保存到/www/lib/[plugin folder]/


Disabling ssl on node and bower is bad for security and there are better instructions on how to accomplish these tasks the right way, however this is how I got it to work inside my corporate office environment in a short amount of time. 在节点和Bower上禁用ssl不利于安全,并且有更好的说明说明如何以正确的方式完成这些任务,但是这就是我在短时间内在公司办公环境中工作的方式。

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

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