本文介绍了在Cordova中使用Angular的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将cord 5添加到cordova并创建一个项目.而且不,我不想使用离子性离子.

I am trying to add angular 5 to cordova and create a project. And no I DO NOT want to use ionic.

我正在网上关注以下教程 https://medium.com/@ nacojohn/convert-your-angular-project-to-mobile-app-using-cordova-f0384a7711a6

I am following the following tutorial on the webhttps://medium.com/@nacojohn/convert-your-angular-project-to-mobile-app-using-cordova-f0384a7711a6

当我运行ng serve时,我的应用程序将在浏览器中启动,当我执行cordova build android时,我的应用程序将成功构建.

when I run ng serve my app launches in the browser and when I do cordova build android my app is built successfully.

但是,一旦我在模拟器中启动该应用程序,我就会收到以下错误和白屏

But as soon as I launch the app in an emulator I get the following error and a white screen

compiler.js:16014 Uncaught TypeError: undefined is not a function

让我知道问题出在哪里吗?

Do let me know where is the issue?

谢谢

注意:我很容易使用angular cli生成的启动项目,这就是为什么我不添加任何代码的原因.

Note: I am simple using the started project generated by angular cli which is why I am not adding any code.

推荐答案

如果可以,请尝试在实际设备上运行它.模拟器遇到与Angular 5浏览器支持不兼容的过时浏览器的问题- https://angular.io/指南/浏览器支持.我尝试了上面的方法,它在我的设备上成功启动.

If you can, try running it on a real device. Emulators have issues with outdated browsers which aren't compatible with Angular 5 browser support - https://angular.io/guide/browser-support. I tried the above and it was launching successfully on my device.

要解决此问题,我通过以下方式在较旧的浏览器上启用了ES6支持:

To sort this out, I enabled the ES6 support on older browsers by:

  1. 在/src文件夹中编辑polyfills.ts.取消注释以下几行

import 'core-js/es6/symbol';

import 'core-js/es6/object';

import 'core-js/es6/function';

import 'core-js/es6/parse-int';

import 'core-js/es6/parse-float';

import 'core-js/es6/number';

import 'core-js/es6/math';

import 'core-js/es6/string';

import 'core-js/es6/date';

import 'core-js/es6/array';

import 'core-js/es6/regexp';

import 'core-js/es6/map';

import 'core-js/es6/weak-map';

import 'core-js/es6/set';

  1. 运行ng build命令,最后运行cordova build android
  1. Run the ng build command and finally cordova build android

以上步骤为我排序了.

致谢

这篇关于在Cordova中使用Angular的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 00:59