当我研究电子时,我找到了2种获取BrowserWindow对象的方法.
const {BrowserWindow} = require('electron')
和
const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
JavaScript中的const和const {}有什么区别?
我无法理解为什么const {}可以工作.我是否想念JS的重要内容?
解决方法:
这两段代码是等价的,但第一段是使用ES6 destructuring assignment更短.
以下是它如何工作的简单示例:
const obj = {
name: "Fred",
age: 42,
id: 1
}
//simple destructuring
const { name } = obj;
console.log("name", name);
//assigning multiple variables at one time
const { age, id } = obj;
console.log("age", age);
console.log("id", id);
//using different names for the properties
const { name: personName } = obj;
console.log("personName", personName);
原文地址:https://codeday.me/bug/20190928/1826545.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。