在 electron 下我使用了
win = new BrowserWindow({width: 800, height: 600})
win.loadURL("https://github.com/login");
win.webContents.on('dom-ready', () => {
new Login().init();
})
我如何获取该页面的元素
我尝试了win.document.getElementById('login_field'); 然后报错了,
后来尝试用remote 模块,写了一个类叫login
const currentWeb = require("electron").remote.getCurrentWebContents;
class Login {
constructor() {
}
init() {
let userInput = document.getElementById('login_field');
userInput.value = '123123';
}
}
module.exports = Login;
同样的报错了,
const XXX = document.querySelector("#XXX");