Ionic 项目中的 Bower 包应该在 IOS 上工作吗?

Should bower packages in Ionic project work on IOS?

我在我的 Ionic 项目中添加了两个 bower 包(angular-md5 和 angular-momentjs)。它们在 Chrome 中运行良好,但在 iOS 模拟器中根本不起作用。我不确定在模拟器中调试这些类型问题的正确方法,如果它们因为应用程序的创建方式而浮出水面,或者如果添加第三方 JavaScript 库甚至由离子支持。感谢任何帮助,谢谢!

是的,Ionic 支持 Bower 包。事实上,Ionic 的库由 Bower 安装并保持最新。

要在 iOS 模拟器中调试应用程序 运行,请遵循以下说明(摘自 this simple tutorial):

  1. In Settings.app on your device, select Safari > Advanced and then enable Web Inspector.
  2. Connect your device to your computer via your cable.
  3. Load the web page you want to inspect in Mobile Safari.
  4. Now, in Safari on your desktop, select Develop > iPhone Simulator and then select the appropriate page from the list.

If you don’t see the Develop menu then you need to enable it in Safari’s Preferences. Select Safari > Preferences > Advanced and check Show Develop menu in menu bar.

当您打开 Safari 网络检查器时,您可能会在控制台中看到几个错误。根据我的经验,最常见的错误是使用绝对路径来包含脚本,如下所示:

<script src="/lib/angular-md5/angular-md5.js"></script>

Chrome支持绝对路径,iOS不支持。使用相对路径解决问题,记住 index.html 位于顶级目录:

<script src="lib/angular-md5/angular-md5.js"></script>