본문 바로가기

컴퓨터/Electron

Electron HTML 보여주기

1. main.js

const { BrowserWindow } = require('electron');
const path = require('path');

const mainWindow = new BrowserWindow({ width: 800, height: 600 });

const data = { name: 'John Doe', age: 30 }; // 전달할 데이터 객체

mainWindow.loadFile(path.join(__dirname, 'index.html'), { query: data });

  전달할 데이터가 없다면, { query: data } 는 생략 가능하다.

2. index.html 안의 index.js

const params = new URLSearchParams(window.location.search);
const name = params.get('name');
const age = params.get('age');

'컴퓨터 > Electron' 카테고리의 다른 글

Electron 환경변수  (0) 2023.04.26
Electron path  (0) 2023.04.24
Electron 모듈화  (0) 2023.04.24
Electron 상단 메뉴 (main menu)  (0) 2023.04.24
Electron MariaDB  (0) 2023.04.23