script中的require引用没效果

来源:2-2 创建 browserWindow

菜鸟x

2019-08-12

script中的require引用没效果

写回答

4回答

letconst

2019-10-12

我也遇到这个问题,在script中require无效,src可以,但最后alert出'undefined'。

//img1.sycdn.imooc.com/szimg/5da1a7cd0891186607860487.jpg

//img.mukewang.com/szimg/5da1a7cd085300af07200639.jpg

//img.mukewang.com/szimg/5da1a7e7081813fd05160100.jpg


0
1
letconst
我自己解决了,单词拼写问题,少了个s: alert(process.version.node) => alert(process.versions.node)
2019-10-12
共1条回复

飘渺的心意

2019-09-09

script src引用可以

0
0

菜鸟x

提问者

2019-08-13

const { app, BrowserWindow } = require('electron')

app.on('ready', () => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreference: {
nodeIntegration: true
}
})
mainWindow.loadFile('index.html')
const secondWindow = new BrowserWindow({
width: 300,
height: 300,
webPreference: {
nodeIntegration: true
},
parent: mainWindow
})
secondWindow.loadFile('second.html')
})

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<meta http-equiv="X-UA-Compatible" content="ie=edge" />

<title>Hellow World!</title>

</head>

<body>

<h1>Hellow World!</h1>

<script>

require('./renderer.js')

</script>

</body>

</html>

// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// All of the Node.js APIs are available in this process.
alert(process.versions.node)
alert(111111)


0
0

张轩

2019-08-12

同学是否可以提供代码 看下

0
2
motys
引入没有弹框,怎么回事啊,老师
2019-12-30
共2条回复

Electron开发仿网易云音乐播放器

站内首门Electron课程,让你更专注应用的核心开发

3428 学习 · 159 问题

查看课程