gpt4 book ai didi

reactjs - 如何使用 Electron react 样板正确设置 Material 用户界面

转载 作者:行者123 更新时间:2023-12-03 13:44:56 25 4
gpt4 key购买 nike

我在使用 electro-react-boilerplate 运行的material-ui (v4.9.5) 库时遇到问题。重现:

  1. 关注installation tutorial
  2. yarn 添加@material-ui/core
  3. 从库中添加一些小部件:
diff --git a/app/components/Home.tsx b/app/components/Home.tsx
index 20748ab..f4f9a21 100644
--- a/app/components/Home.tsx
+++ b/app/components/Home.tsx
@@ -1,11 +1,13 @@
import React from 'react';
import { Link } from 'react-router-dom';
+import { Button } from '@material-ui/core';
import routes from '../constants/routes.json';
import styles from './Home.css';

export default function Home() {
return (
<div className={styles.container} data-tid="container">
+ <Button>Hello</Button>
<h2>Home</h2>
<Link to={routes.COUNTER}>to Counter</Link>
</div>

现在,当您运行yarn dev时,一切都运行良好。然而,yarn start 会产生:

init.ts:204 Unable to load preload script: /home/vasniktel/boiler-test/app/dist/renderer.prod.js
(anonymous) @ init.ts:204
init.ts:205 TypeError: Cannot use 'in' operator to search for 'ontouchstart' in null
at Module../app/index.tsx (/home/vasniktel/boiler-test/app/dist/renderer.prod.js:2)
at n (/home/vasniktel/boiler-test/app/dist/renderer.prod.js:2)
at module.exports../app/app.global.css (/home/vasniktel/boiler-test/app/dist/renderer.prod.js:2)
at Object.<anonymous> (/home/vasniktel/boiler-test/app/dist/renderer.prod.js:2)
at Object.<anonymous> (/home/vasniktel/boiler-test/app/dist/renderer.prod.js:3)
at Module._compile (internal/modules/cjs/loader.js:880)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:892)
at Module.load (internal/modules/cjs/loader.js:735)
at Module._load (internal/modules/cjs/loader.js:648)
at Module._load (electron/js2c/asar.js:717)
(anonymous) @ init.ts:205

有什么办法可以解决这个问题吗?

最佳答案

似乎从 main.dev.ts 文件中删除这些行可以解决问题:

@@ -58,14 +58,9 @@ const createWindow = async () => {
show: false,
width: 1024,
height: 728,
- webPreferences:
- process.env.NODE_ENV === 'development' || process.env.E2E_BUILD === 'true'
- ? {
- nodeIntegration: true
- }
- : {
- preload: path.join(__dirname, 'dist/renderer.prod.js')
- }
+ webPreferences: {
+ nodeIntegration: true
+ }
});

关于reactjs - 如何使用 Electron react 样板正确设置 Material 用户界面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60473495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com