Nodejs打開瀏覽器


有沒有為nodejs編譯完成后,還要打開瀏覽器,輸入網址,而感到煩惱呢?放心,這就來拯救你。

今天介紹的這個模塊叫做open模塊。它的功能就是主動打開瀏覽器,免去你的一些煩惱。

安裝

$ npm install opn --save

用法

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']});

怎么樣?很簡單吧,還等什么呢。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM