当 textisolation 为真时如何使用 node

编程入门 行业动态 更新时间:2024-10-04 05:34:11

当 textisolation 为真时<a href=https://www.elefans.com/category/jswz/34/1771452.html style=如何使用 node"/>

当 textisolation 为真时如何使用 node

我目前正在使用 Electron 制作应用程序,但是当我打包我的应用程序时,当我设置参数时出现白屏

textisolation: true
.

但是当我将它设置为

false
时,我的模块如
jquery
sqlite3
没有定义。

这里是三段代码:

main.js

const path = require('path');
const { app, BrowserWindow, screen } = require('electron')
const EventEmitter = require('events')
appmandLine.appendSwitch("ignore-certificate-errors");
const loadingEvents = new EventEmitter()
let win
app.on('ready', () => {  
  const { width, height } = screen.getPrimaryDisplay().workAreaSize
  window = new BrowserWindow({
    width,
    height,
    minWidth:970,
    minHeight:390,
    icon: 'icon.png',
    webPreferences: {
      nodeIntegration: true,
      enableRemoteModule: true,
      contextIsolation: true,
      webSecurity: false,
    }
  })
  
  window.loadFile((path.join(__dirname, '/html/loading.html')))

  // Our loadingEvents object listens for 'finished'
  loadingEvents.on('finished', () => {
    window.loadFile((path.join(__dirname, '/html/index.html')))
    window.webContents.openDevTools()
  })

  setTimeout(() => loadingEvents.emit('finished'), 5000)
})

index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <!--  -->
    <link rel="stylesheet" href="../css/index.css" type="text/css">
    <title>MyApp</title>
  </head>
  <body class="container">
    <div class="topnav" id="myTopnav">
      <a id="name">MyApp</a>
      <a href='index.html'>Home</a>
      <a href='get.html'>Live TV</a>
      <a href='post.html'>Movies</a>
      <a href='inline.html'>Series</a>
      </a>
    </div>
  </body>
  <script src="../js/index.js"></script>
</html>

index.js

const { get } = require('jquery');
var $ = jQuery = require("jquery")
var mysql = require('mysql');
var sq = require('sqlite3');
require('dotenv').config()

我尝试了几种解决方案,但不幸的是没有成功。

你知道解决这个问题的方法吗?

非常感谢您的帮助。

回答如下:

更多推荐

当 textisolation 为真时如何使用 node

本文发布于:2024-05-31 00:39:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771091.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   textisolation   node

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!