久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

類型錯誤:window.require 不是函數

TypeError: window.require is not a function(類型錯誤:window.require 不是函數)
本文介紹了類型錯誤:window.require 不是函數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試構建一個電子應用程序并想使用 window.require.不幸的是,編譯器說TypeError:window.require 不是函數".具有諷刺意味的是,require在 main.js 中有效.

Im trying to build an electron app and want to use window.require. Unfortunately the compiler says "TypeError: window.require is not a function". Ironically require works only in main.js.

這是我試圖運行的代碼:

Here the code Im trying to run:

const electron = window.require('electron')
const low =  window.require('lowdb')
const FileSync = window.require('lowdb/adapters/FileSync')

我在另一篇文章中讀到有人遇到了同樣的問題,并通過將此代碼添加到 .html 文件中解決了這個問題:

I read in another post that somebody have had the same problem and it was fixed by adding this code into the .html file:

    <script type="text/javascript" src="../../../Gehaltseinstellungen_Hinzufügen.js">
        window.nodeRequire = require;
        delete window.require;
        delete window.exports;
        delete window.module;
    </script>

作者還說使用nodeRequire"而不是 require 可以解決問題,但它并沒有......

Also the author said using "nodeRequire" instead of require would solve the problem but it doesn't...

我讀到的另一個選項是在激活渲染過程時 NodeIntegration 設置為 false,但我不知道如何在渲染時激活 Node.

Another option I read about is that the NodeIntegration is set to false while the rendering process is activated, but I don't know how to activate Node while rendering.

推薦答案

不清楚您使用的是什么版本的 Electron.您使用的語法是非標準的.

It is unclear what version of Electron you are using. The syntax you are using is non-standard.

首先 - 如果您使用的是 Electron 5.0,BrowserWindows 中的 nodeIntegration 默認為 false,因此您需要在創建窗口時明確指定它:

First – if you are using Electron 5.0, nodeIntegration is false by default in BrowserWindows so you need to specify it explicitly when you create your window:

mainWindow = new BrowserWindow({
  width: 800,
  height: 600,
  webPreferences: {
    nodeIntegration: true
  }
})

<小時>

鑒于上述情況,以下語法可以正常工作(即不需要窗口"引用):


Given the above, the syntax below works fine (i.e. no 'window' reference needed):

const { ipcRenderer, remote } = require('electron');

這篇關于類型錯誤:window.require 不是函數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 日韩av在线免费 | 国产人成精品一区二区三 | 91精品国产综合久久福利软件 | 91亚洲视频在线 | 国产欧美一区二区三区日本久久久 | 天堂av中文 | 日韩三级 | 韩国毛片视频 | 亚洲欧美中文日韩在线v日本 | 精品欧美一区二区在线观看欧美熟 | 久久久视频在线 | 国产免费一区二区三区最新6 | 日韩一区二区黄色片 | 亚洲人成人一区二区在线观看 | 视频在线一区二区 | 亚洲资源站 | 成人h免费观看视频 | 欧美啪啪网站 | 欧美极品少妇xxxxⅹ免费视频 | 在线免费国产视频 | 人人干97 | 欧美成人影院 | 国产99久久久国产精品 | 在线观看中文字幕dvd播放 | av一区二区三区 | 国产精品毛片一区二区三区 | 一本一道久久a久久精品综合 | hitomi一区二区三区精品 | 日韩视频在线一区 | 欧美v日韩| 精品一区二区免费视频 | 无码日韩精品一区二区免费 | 精品在线一区二区三区 | 国产观看 | 欧美一区二区三区久久精品 | 国产一级在线视频 | 亚洲成人一区二区 | 荷兰欧美一级毛片 | 在线观看成人免费视频 | 久久综合一区 | 亚洲一区二区av |