electron中要获取鼠标的横坐标和纵坐标,需要先引入screen模块
例子如下:
const remote = require('electron').remote;
const screen = remote.screen;
const {x,y} = screen.getCursorScreenPoint();//获取到鼠标的横坐标和纵坐标
console.log(x,y);
const screen = remote.screen;
const {x,y} = screen.getCursorScreenPoint();//获取到鼠标的横坐标和纵坐标
console.log(x,y);