JavaScript (node.js) 中的 {app, BrowserWindow} 是什么意思?

What does {app, BrowserWindow} means in JavaScript (node.js)?(JavaScript (node.js) 中的 {app, BrowserWindow} 是什么意思?)
本文介绍了JavaScript (node.js) 中的 {app, BrowserWindow} 是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

在阅读使用 electron 制作软件的文档时,我在 index.js 文件(一般执行开始的文件)

While reading docs of making softwares with electron, I came across this type of code in the beginning of index.js file (the file where generally execution starts)

const {app, BrowserWindow} = require('electron')

{app, BrowserWindow}(语法,而不是关键字)的真正含义是什么?它是 JavaScript 语法,还是 node.js 的东西,还是与电子相关的东西?

What does {app, BrowserWindow} (the syntax, not the keywords) really means? Is it a JavaScript syntax, or a node.js thing or something exclusively related to electron?

推荐答案

这种语法称为对象解构",它是最新版本的 JavaScript(JavaScript2015 aka ECMAScript 6/ES6)的一个特性 - appBrowserWindow 只是您希望在应用程序的这一部分中使用的 electron 的特定部分.

This syntax is called 'object destructuring', and it is a feature of the latest version of JavaScript (JavaScript2015 aka ECMAScript 6/ES6) - app and BrowserWindow are just particular parts of electron that you want to use in this portion of your application.

这是一种简化代码并轻松引用依赖项关键部分的方法.

It's a way to simplify your code and to easily reference critical parts of a dependency.

这是 https:///developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

var o = {p: 42, q: true};
var {p, q} = o;

console.log(p); // 42
console.log(q); // true

所以在你的例子中,electron 是一个导入的模块,看起来像(同样,这里过于简单化了):

So in your case, electron is an imported module that would look something like (again, a gross oversimplification here):

var electron = {
    app: {
        greet: () => {
            console.log("Hello, world!")
        }
    },
    BrowserWindow: {/* some other stuff *
                本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!
                
上一篇:在预期返回 void 的函数参数中返回 Promise 下一篇:webview的电子预加载脚本不起作用?
相关文档推荐 谷歌应用程序脚本从二进制文件中获取字节范围 Google apps script get range of bytes from binary file(谷歌应用程序脚本从二进制文件中获取字节范围) 使用 Google 脚本从 Google Drive 发送多个附件 Sending Multiple attachments with Google Script from Google Drive(使用 Google 脚本从 Google Drive 发送多个附件) 在您的公司网络中分发适用于表格的 Google Apps 脚本 Distributing Google Apps Scripts for Sheets in your company network(在您的公司网络中分发适用于表格的 Google Apps 脚本) 使用 javascript 将文件从任何人上传到我的谷歌驱动器 Upload file to my google drive from anyone using javascript(使用 javascript 将文件从任何人上传到我的谷歌驱动器) “共享驱动器"Google Apps 脚本中的支持 quot;Shared Drivequot; support in Google Apps Script(“共享驱动器Google Apps 脚本中的支持) Angular 2+ HTTP POST 和 GDrive API.带名称的可恢复文件上传 Angular 2+ HTTP POST and GDrive API. Resumable file upload with name(Angular 2+ HTTP POST 和 GDrive API.带名称的可恢复文件上传)
栏目导航 前端开发问题Java开发问题C/C++开发问题Python开发问题C#/.NET开发问题php开发问题移动开发问题数据库问题 最新文章 • AJAX在GBK编码页面中传中文参数乱码... • 使用选择器在 CSS 中选择元素的前一... • 如何在 JS 中获取 CryptoJS.HmacSHA2... • 使用 css 复制 html 元素... • 管理静态 HTML 网站中重复代码的最佳... • JWT 未解码“JWT malformed";-... • PBEWithMD5AndTripleDES/CBC/PKCS5Pa... • 使用 Discord.js 向频道发送消息时遇... • 我正在尝试制作 discord.js 头像命令... • CSS 特性如何决定应用哪些样式?... • nth-child 中奇数/偶数子元素的问题... • nth-子 CSS 选择器... 热门文章 • AJAX在GBK编码页面中传中文参数乱码... • 使用选择器在 CSS 中选择元素的前一... • 如何在 JS 中获取 CryptoJS.HmacSHA2... • 使用 css 复制 html 元素... • 管理静态 HTML 网站中重复代码的最佳... • JWT 未解码“JWT malformed";-... • PBEWithMD5AndTripleDES/CBC/PKCS5Pa... • 使用 Discord.js 向频道发送消息时遇... • 我正在尝试制作 discord.js 头像命令... • CSS 特性如何决定应用哪些样式?... • nth-child 中奇数/偶数子元素的问题... • nth-子 CSS 选择器... 热门标签 织梦资讯网 织梦模板 dede 外语学校 织梦鬼故事 竞价网站源码 竞价培训网 门户网站 织梦二次开发 织梦笑话网 dedecms笑话网 织梦源码 网站建设 搞笑图片 织梦教程 旅游网站源码 织梦旅游网 学校培训 html5 企业织梦源码 医院源码 后台样式 移动营销页 整形医院 大学医院 新手建站 客服代码 洗衣机维修 企业网站 淘宝客 导航菜单 教育网站 学校源码 装修网站 装修模板 美容整形 女性健康 妈妈网 机械源码 建站公司 珠宝首饰 苹果网站 手机资讯 美女图片 织梦模版打包 妇科源码 安卓市场源码 男性时尚网 健康之家 app应用网站 笑话网站 下载站 美女图片网 中医院网站 家装网站源码 QQ网站 标牌网站 魔兽世界网 淘宝客源码 YY网站源码 别墅设计网站 服装搭配网 宝宝起名网 站长网站 婚庆网站 脑科医院源码 笑话源码 肝胆医院 意外怀孕源码 工作室
网站首页 - 免责声明- 最新公告- 充值相关 - 网站地图 Copyright © 2021-2022 深圳市沃梦达电子商务有限公司 All Rights Reserved. 粤ICP备14083021号