久久久久久久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 服務器時的歡迎消息)
主站蜘蛛池模板: 欧美日韩精品一区 | 久久久久国产一区二区三区 | 在线观看视频91 | 黄色一级免费看 | 天天拍天天草 | 亚洲国产黄 | 亚洲精品久久久久中文字幕二区 | 亚洲欧美一区二区三区国产精品 | 免费观看www7722午夜电影 | 欧美一区二区三区在线观看 | 天天躁日日躁狠狠躁白人 | 久久久www成人免费无遮挡大片 | 日日干日日操 | 激情影院久久 | 久久精品| 天天操综合网站 | 久久国产电影 | 羞羞涩涩在线观看 | 中文字幕第一页在线 | 国产在线97| 成人在线播放网站 | 国产精品色av | 中文字幕在线看人 | 国产美女精品 | 亚洲视频在线一区 | 最新伦理片 | 亚洲最大的成人网 | 麻豆国产精品777777在线 | 久久精品色视频 | 精品免费视频一区二区 | 狠狠操狠狠色 | 成人黄色网址大全 | 亚洲一二三区在线观看 | 欧美日韩亚洲二区 | 日韩一区二区在线看 | 毛片免费视频 | 日韩精品一区二区三区视频播放 | 亚洲一区二区三区在线播放 | 一区二区三区四区在线视频 | 成人国产一区二区三区精品麻豆 | 懂色中文一区二区在线播放 |