<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 第20章.API簡介 > 如何使用 Node.js 和 Electron APIs。 所有 [Node.js 的內建模塊](https://nodejs.org/api/) 都可以在 Electron 中使用,第三方 node 模塊同樣可以完全支持(包括 [原生模塊](../tutorial/using-native-node-modules.md))。 Electron 還提供了一些額外的內建模塊用于開發原生桌面應用。一些模塊只能在主進程中使用,一些只能在渲染進程(web 頁面)中使用,還有一些在兩種進程中都可以使用。 基本的原則是:如果一個模塊是 [GUI][gui] 或者底層系統相關的,那么它只能用在主進程中。你需要熟悉 [主進程 vs. 渲染進程](../tutorial/quick-start.md#main-process) 腳本的概念來使用這些模塊。 主進程腳本就像一般的 Node.js 腳本: ```javascript const {app, BrowserWindow} = require('electron') let win = null app.on('ready', () => { win = new BrowserWindow({width: 800, height: 600}) win.loadURL('https://github.com') }) ``` 渲染進程和一般的 web 頁面沒有什么區別,除了額外使用 node 模塊的能力之外: ```html <!DOCTYPE html> <html> <body> <script> const {app} = require('electron').remote console.log(app.getVersion()) </script> </body> </html> ``` 要運行你的 應用,閱讀 [Run your app](../tutorial/quick-start.md#run-your-app)。 ## 解構賦值 從 0.37 起,你可以使用 [解構賦值][destructuring-assignment] 以更容易的使用內建模塊。 ```javascript const {app, BrowserWindow} = require('electron') let win app.on('ready', () => { win = new BrowserWindow() win.loadURL('https://github.com') }) ``` 如果你需要整個 `electron` 模塊,可以 require 它,然后使用結構從 `electron` 中訪問單獨的模塊。 ```javascript const electron = require('electron') const {app, BrowserWindow} = electron let win app.on('ready', () => { win = new BrowserWindow() win.loadURL('https://github.com') }) ``` 這和下面的代碼是等效的: ```javascript const electron = require('electron') const app = electron.app const BrowserWindow = electron.BrowserWindow let win app.on('ready', () => { win = new BrowserWindow() win.loadURL('https://github.com') }) ``` * [gui]: https://en.wikipedia.org/wiki/Graphical_user_interface * [destructuring-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看