javascript - 运行描述中给出的 cordova 应用程序时出现 2-3 个弹出窗口,然后浏览器卡住

标签 javascript android cordova angular phonegap-build

gap_init:2 
gap:[null,"CoreAndroid","messageChannel","CoreAndroid1594682113"] 
gap:[null,"CoreAndroid","show","CoreAndroid1594682114"]

我正在尝试使用Angular js 2.0开发Cordova应用程序 我创建了 Cordova hello world 和 Angular js 2.0 hello world 然后我合并了这两件事

但是在运行应用程序时,会生成这些弹出窗口,然后什么也没有发生

最佳答案

您使用 angular-cli 制作项目,您制作一个 cordova 项目然后在您的 angular-cli.json 文件中 -> 更改 cordova 的 www 文件夹的路径。

然后,当您进行 ng prod build 时,您的资源将被复制到 cordova 的 www 文件夹中。

我为此写了一个cordova hook,

const fs = require('fs');
const execSync = require('child_process').execSync;



module.exports = function(context) {
    const basePath = context.opts.projectRoot;
    const baseWWW = basePath + '/www';

process.chdir('../bmi-surgical-app');
console.log(`New directory: ${process.cwd()}`);

    execSync("ng build --prod --base-href .",{stdio:[0,1,2]});

    var files = fs.readdirSync(baseWWW);
    for (var i = 0; i < files.length; i++) {
      if (files[i].endsWith('.gz')) {
        fs.unlinkSync(baseWWW + '/' + files[i]);
      }
    }
    fs.writeFileSync(baseWWW + '/.gitignore', `# Ignore everything in this directory

*
# Except this file
!.gitignore
`);


};

但是,还有许多更好的选择,例如 NativeScript 和 Ionic 2。

关于javascript - 运行描述中给出的 cordova 应用程序时出现 2-3 个弹出窗口,然后浏览器卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42268888/

相关文章:

android - 如何使用 Intent 将视频分享到任何应用程序?

javascript - WebAuthn: navigator.credentials.create() 是否可以从本地主机到另一个(子)域?

javascript - React Hooks 模态传递状态?

javascript - 为什么 ng-disabled 在 3 秒后没有启用按钮?

android - 将 fragment 从一个 Activity 加载到另一个已经在后台的 Activity

cordova - 如何使用 ionic View 在应用程序中显示console.log()

javascript - 使用赋值解构交换项在函数内部不起作用

android - Material Design 中的 ActionBar 弹出窗口

jquery - 使用 Jquery 的类似 Tabbar 的效果

angularjs - 前端与后端本地化策略比较