如何在Ionic V1/Angular 1.x中导入ionic.native.js

Ric*_*evi 7 ionic-framework

现在很难看到Ionic 2出来的文件或例子.

我想ionic.native.js在旧的Ionic V1项目中使用.事情就是安装npm

npm install ionic-native --save

但是现在我有大量的npm模块node_modules/作为依赖.离子文献说:

如果您使用的是Angular 1.x或普通的ES5 JavaScript,则需要将ionic.native.js添加到index.html

但他们没有举例说明如何把它放在index.html- 这就是我的问题.

目前我的文件位于:

> find . -name ionic.native.js
./node_modules/ionic-native/dist/ionic.native.js
Run Code Online (Sandbox Code Playgroud)

node_modules/dir 没有任务...所以如何将其导入index.html?或者我在错误的地方使用了npm命令?(目前它位于项目的根目录,其中有gulpfile.js生命)

小智 8

我遇到了和你一样的问题.

最后,最终解决它的是使用:

bower install ionic-native --save
Run Code Online (Sandbox Code Playgroud)

这会将文件添加到lib /目录,该目录可从索引页面访问.

然后在index.html文件中添加:

<script src="lib/ionic-native/ionic.native.js"></script>
Run Code Online (Sandbox Code Playgroud)

希望这有帮助!