Electron中 提示:Uncaught ReferenceError: process is not defined

場景

用HTML和CSS和JS構建跨平臺桌面應用程序的開源庫Electron的介紹以及搭建HelloWorld:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/106413828

在上面搭建起來Electron的HelloWorld程序後。

想要在js中使用process對象時提示:

Uncaught ReferenceError: process is not defined

 

注:

博客:
https://blog.csdn.net/badao_liumang_qizhi
關注公衆號
霸道的程序猿
獲取編程相關電子書、教程推送與免費下載。

實現

本來是想在js中通過process獲取一些信息的

var btn=document.getElementById('buttonProcess');
   
btn.onclick=getProcessInfo;

 function getProcessInfo()
{
    console.log("getProcessInfo**********************");

    console.log("getCPUUsage:",process.getCPUUsage);
     //cpu操作位數
    console.log("arch:",process.arch);
    //環境變量
    console.log("env:",process.env);
}

如果想使用process對象要在main.js中添加如下代碼

nodeIntegration:true

添加位置如下

 

然後重啓項目!重啓項目!重啓項目!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章