open 介绍
打开url,文件,可执行文件 跨平台的。这意味着可以在命令行工具和脚本中使用,而不是在浏览器中。
https://github.com/sindresorhus/open
$ npm install open
用法
const open = require('open');
// Opens the image in the default image viewer and waits for the opened app to quit.
await open('unicorn.png', {wait: true});
console.log('The image viewer app quit');
// Opens the URL in the default browser.
await open('https://sindresorhus.com');
// Opens the URL in a specified browser.
await open('https://sindresorhus.com', {app: {name: 'firefox'}});
// Specify app arguments.
await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
// Open an app
await open.openApp('xcode');
// Open an app with arguments
await open.openApp(open.apps.chrome, {arguments: ['--incognito']});
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END