npm模块之opn使用教程(译)
来源:互联网 发布:unity3d开发流程 编辑:程序博客网 时间:2024/06/06 07:43
原文链接
安装
$ npm install --save opn
使用方法
const opn = require('opn');// opens the image in the default image viewer opn('unicorn.png').then(() => { // image viewer closed });// opens the url in the default browser opn('http://sindresorhus.com');// specify the app to open in opn('http://sindresorhus.com', {app: 'firefox'});// specify app arguments opn('http://sindresorhus.com', {app: ['google chrome', '--incognito']});
接口
在OS X上用命令open
,在Windows上用start
,在其他平台上使用xdg-open
。
opn(target, [options])
返回生成的子进程的promise
。 你通常不需要使用这个任何东西,但它可以是有用的,如果你想附加自定义事件监听器或直接对生成的进程执行其他操作。
target:
必需
类型:string
你想打开的东西。 可以是URL,文件或可执行文件。
在默认应用中打开文件类型。 例如。 URL在您的默认浏览器中打开。
options:
类型:object
wait
类型: boolean
默认: true
等待打开的应用程序在调用callback
之前退出。 如果为false
,则会在打开应用程序时立即调用。
在Windows上,您必须显式指定一个应用程序才能等待。
app:
类型: string
,array
指定要使用的target
打开的应用程序,或包含应用程序和应用程序参数的数组。
应用名称取决于平台。 不要在可重用模块中硬编码。 例如。 Chrome是OS X上的google chrome
,Linux上的google-chrome
和Windows上的chrome
。
0 0
- npm模块之opn使用教程(译)
- npm模块之http-proxy-middleware使用教程(译)
- npm模块之http-proxy-middleware使用教程(译)
- npm模块之http-proxy-middleware使用教程(译)
- Node.js模块与npm item2—NPM使用
- 使用npm制作nodejs模块包
- 使用npm制作nodejs模块包
- 如何在Meteor中使用npm模块?
- nodejs+npm+gulp使用详细教程
- 我的Node.js学习之路(二)NPM模块管理
- npm 模块笔记(一): config
- ESP8266模块使用教程
- node.js之npm安装模块的路径
- npm清除未被使用的模块命令
- gulp+bower体系如何使用browserify调用npm模块
- 使用npm管理weex组件及公共模块库
- nodejs使用npm发布模块带npm报错(verbose stack Error: Invalid name: "")解决
- Nodejs之NPM安装与使用
- 设计模式的学习
- Swust OJ 0002 Prime Path
- 2017/02/24学习日志
- 快速直接解决AndroidStudio导入项目中的gradle问题
- Android属性动画(PropertyAnimation)(下)
- npm模块之opn使用教程(译)
- 官方录音播放demo
- 带参数的装饰器
- 将本地nodejs服务器的代码提交到github
- Oracle 11g服务详细介绍及哪些服务是必须开启的
- C++11 并发指南六(atomic 类型详解一 atomic_flag 介绍)
- C++11 并发指南五(std::condition_variable 详解)
- 167. Two Sum II
- 第三方支付回调地址代理转发