【发布时间】:2020-12-12 12:44:19
【问题描述】:
所以我试图让 monaco 使用 react 和 electron,它会加载加载程序文件,但它在加载时卡住了。 init 函数不运行 console.log 与 monaco 实例的承诺。我做错了什么?
import React, { useEffect, useRef, useState } from "react";
import Editor, { monaco } from "@monaco-editor/react";
const path = window.require("path");
function ensureFirstBackSlash(str) {
return str.length > 0 && str.charAt(0) !== "/" ? "/" + str : str;
}
function uriFromPath(_path) {
const pathName = path.resolve(_path).replace(/\\/g, "/");
return encodeURI("file://" + ensureFirstBackSlash(pathName));
}
function App() {
useEffect(() => {
monaco.config({
paths: {
vs: uriFromPath(path.join(__dirname, "node_modules/monaco-editor/min")),
},
});
monaco.init().then((monacoInstance) => console.log(monacoInstance));
}, []);
return (
<div>
<Editor width="500" height="500" language="javascript" value={""} />
</div>
</div>
);
}
export default App;
【问题讨论】:
-
我的加载消息消失了,但它现在是一个空屏幕。电子抛出错误
GL ERROR :GL_INVALID_FRAMEBUFFER_OPERATION : glDrawArrays: framebuffer incomplete
标签: javascript node.js reactjs electron