添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

你不能点击穿透透明区域。 我们将引入一个 API 来设置窗口形状以解决此问题, 请参阅 our issue 以了解详细信息。

这个issue提出时间是2015年!
关于 不规则 透明 窗口的一些问题:
如果使用

-webkit-app-region: drag;

此时可以随意拖动窗口,而代价是Electron渲染进程(即页面)无法捕获DOM鼠标事件

Event "will-move"的Bug(特性)

newBounds Rectangle - Location the window is being moved to.

这个返回数据的坐标系和screen.getPrimaryDisplay().workAreaSize;
不是相同的,在Windows上screen返回的是缩放过的数据,即DPI调整(多见于高分屏)过后的,will-move返回的是物理像素坐标

问题描述
跟随官网的实例,再进行主进程到渲染进程通信的时候,出现了错误

//在渲染器进程 (网页) 中。

const { ipcRenderer } = require('electron')
console.log(ipcRenderer.sendSync('synchronous-message', 'ping')) // prints "pong"
ipcRenderer.on('asynchronous-reply', (event, arg) => {
  console.log(arg) // prints "pong"
ipcRenderer.send('asynchronous-message', 'ping')

系统报错Uncaught ReferenceError: require is not defined
系统报错

解决方案
开启BrowserWindow的nodeIntegration: true

mainWindow = new BrowserWindow({
  //...
  webPreferences: {
     nodeIntegration: true
 mainWindow = new BrowserWindow({
    width: 1280,
    height: 960,
    webPreferences: {
      nodeIntegration: true,
      enableRemoteModule: true,
  });

I believe you are using the new version of Electron. From v9 version, we are not allowed to use remote on the renderer unless set the enableRemoteModule as true.

Plus in order to load node_moduels on renderer by using require(), we need to also enable the nodeIntegration as well. As require is one of node APIs.

Cannot read property ‘getCurrentWindow’ of undefined

webPreferences: {enableRemoteModule: true}
                                    分析
之前版本使用dialog时选择文件时,可以加入callback,来获取被选择文件的路径,而electron10更新后发生了改动,采用了Promise对象来获取结果。
electron 10之前我们获取文件路径,只需加入callback即可,也就是下述写法,且之前返回的data结果直接是文件的路径。
openDialogDom.onclick = function(){
  remote.dialog.showOpenDialog({
    properties:['openFile']
  },function(data){
    console.log(data)
                                    这句话直译过来就是:TypeError:无法读取未定义的属性“ xxx”
首先去看看属性 ‘xxx’ 有没有定义。没定义的根据实际需求在data中或者方法中定义一下。
1、如果在data中定义了,先看看你的data写对了没,我有一次手误打成了 date ,检查了一下午才看出来o(╥﹏╥)o
2、如果这个数据“xxx”是从后台异步获取的,那就最好在data中先给他个默认值
data() {
   return {
      obj1: '',
      obj2: null.
                                    vue项目中经常会遇到"cannot read property ‘某某某’ of undefined"的报错信息。下面我就简单分析下报错原因及解决方法
info是服务端返回的数据,是一个对象。我们要做的就是把对象里的值放到页面显示,先看一下我出错的代码片段
<div class="shop-header-discounts" @click="toggleSupportShow">
    <div class="discounts-left">
                                    1.低版本的electron,一直正常使用remote,但是升级到electron10.1.2之后remote是undefined,
解决办法:需要进行安装remote并且必须手动设置主窗体webPreferences中enableRemoteModule为true之后才能使用。
安装@electron/remote
npm install --save @electron/remote
在主程序中引入初始化
var BrowserWindow = electron.BrowserWindow
                                    希沃ENOW大前端公司官网:CVTE(广州视源股份)团队:CVTE旗下未来教育希沃软件平台中心enow团队「本文作者:」image.png前言你盼世界,我盼望你无 bug 。Hello 大...