2017-04-05 40 views

回答

0

你可以使用nodejs和命令行,就像这样。

var exec = require('child_process').exec; 
exec('start /max chrome.exe --incognito --app=' + url, function (error, stdout, stderr) { 
    if (error !== null) { 
     console.log('exec error: ' + error); 
    } 
}); 

在这种情况下url将是你想要打开的。在这里我打开Chrome。但是,如果你想打开预定的布朗尔,就把这样的东西。

var exec = require('child_process').exec; 
exec('start /max ' + url, function (error, stdout, stderr) { 
    if (error !== null) { 
     console.log('exec error: ' + error); 
    } 
}); 
1

电子它实际上是非常简单的打开默认浏览器中的任何链接。您只需要从电子导入/需要外壳模块。

import { shell } from 'electron'; 

shell.openExternal('https://example.com'); 

如果你没有使用ES6只是const { shell } = require('electron');

+0

angular2抛出错误“无法找到模块'电子'” –

+0

@MohammadShahid似乎像Angular 2覆盖要求/导入。只要按照这个指南,你应该很好去:http://stackoverflow.com/a/37327006/2004682 – Horst

相关问题