renderer.js中不能使用node API是跟node.js的版本有关系吗?

来源:2-2 创建 browserWindow

ibuole

2022-05-03

// This file is required by the index.html file and will
// be executed in the renderer process for that window.
// No Node.js APIs are available in this process because
// `nodeIntegration` is turned off. Use `preload.js` to
// selectively enable features needed in the rendering
// process.
写回答

4回答

慕后端24501

2022-05-12

主窗口增加 
webPreferences:{

nodeIntegration:true,

contextIsolation: false

}    可以调起来

   
3
1

莫子轩

2022-06-29

补充回答,去官网看了下,老师的是mac系统,因为路径问题导致报错,改为官方写法后就可以了

<script src="./renderer.js"></script>

运行结果

//img.mukewang.com/szimg/62bc48b70999ec8a09840742.jpg

            

2
0

莫子轩

2022-06-29

可以了

0
0

慕后端24501

2022-05-12

同问 我发现我这边也不能调用node api


0
0

深度实战Electron,开发本地音乐播放器

慕课网首门 Electron 课程,专注应用核心开发

2347 学习 · 32 问题

查看课程