How to change default browser of cordova browser platform?

倾然丶 夕夏残阳落幕 提交于 2020-01-12 07:31:11

问题


I don't have chrome installed and I mainly use other browsers for development (opera, yandex etc). But the command:

cordova run browser

uses chrome by default, so it fails with " The system can not find the file chrome.". Can I change which browser cordova uses?


回答1:


The only way to change the default Chrome browser is using the --target option.

As you can see Chrome is the default browser for the run command.

Internally, the cordovaServe.launchBrowser function is called with cli arguments.

This function is defined in the cordova-serve/serve.js file and you can find its body in the cordova-serve/src/browser.js file where you can find the complete list of supported browsers for each platform:

var browsers = {
    'win32': {
        'ie': 'iexplore',
        'chrome': 'chrome --user-data-dir=%TEMP%\\' + dataDir,
        'safari': 'safari',
        'opera': 'opera',
        'firefox': 'firefox',
        'edge': 'microsoft-edge'
    },
    'darwin': {
        'chrome': '"Google Chrome" --args' + chromeArgs,
        'safari': 'safari',
        'firefox': 'firefox',
        'opera': 'opera'
    },
    'linux' : {
        'chrome': 'google-chrome' + chromeArgs ,
        'chromium': 'chromium-browser' + chromeArgs,
        'firefox': 'firefox',
        'opera': 'opera'
    }
};

I hope that this answer will help you to learn a bit more about cordova and the way it works.




回答2:


Test the following command:

cordova run browser --target=firefox



来源:https://stackoverflow.com/questions/38075283/how-to-change-default-browser-of-cordova-browser-platform

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!