won*_*ng2 6 modal-dialog electron
这是我目前的项目结构:
main.js
index.html
download.html
src/index.js
src/style.css
Run Code Online (Sandbox Code Playgroud)
main.js将创建一个BrowserWindow并加载index.html,加载index.js和style.css.
我想创建一个新的模态窗口并download.html在单击按钮时加载index.html.
这是我的代码index.js:
btn.onclick = function() {
let win = new remote.BrowserWindow({
parent: remote.getCurrentWindow(),
modal: true
})
win.loadURL(`file://${__dirname}/download.html`)
}
Run Code Online (Sandbox Code Playgroud)
但它正在加载file://download.html,__dirname在渲染过程中不存在?
No *_*ing 11
刚刚测试了这段代码(下面)并且它可以工作.目录结构是:
main.js
app(目录)
--- index.html
--- app.js(以下代码存在)
--- modal.html
你remote好吗?
"use strict";
const { remote } = require('electron');
function openModal() {
let win = new remote.BrowserWindow({
parent: remote.getCurrentWindow(),
modal: true
})
var theUrl = 'file://' + __dirname + '/modal.html'
console.log('url', theUrl);
win.loadURL(theUrl);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7975 次 |
| 最近记录: |