c# - 如何在反应中访问cefSharp
问题描述
我正在尝试在 C# .net 应用程序中加载 react url。我想在我们的 React 应用程序中访问 cefSharp 对象。像这样
useEffect(() => {
if (typeof CefSharp !== "undefined") {
(async function() {
await CefSharp.BindObjectAsync("cefCustomObject");
cefCustomObject.showDevTools();
cefCustomObject.writetodebug("test","testestestest");
cefCustomObject.opencmd();
})();
}
}, []);
我已经看到在 vue 中使用上面的代码。我想对 react 做同样的事情。编辑:使用窗口对象。现在它为 window.cefCustomObject.showDevTools() 引发错误
useEffect(() => {
if (typeof window.CefSharp !== "undefined") {
(async function() {
await window.CefSharp.BindObjectAsync("cefCustomObject");
window.cefCustomObject.showDevTools();
window.cefCustomObject.writetodebug("test","testestestest");
window.cefCustomObject.opencmd();
})();
}
}, []);
解决方案
推荐阅读
- android - ios android 跨平台http请求api
- python - txt 文件的字数统计并输出到文件
- python - 如何在熊猫中按数据创建嵌套组的平均分布?
- python - 代码将在条件之后打印 i,但不会打印 i 的总和。错误指出“int”对象不可迭代
- haskell - 如何使用 cabal new-test 通过测试选项?
- swift - 禁止警告:复制捆绑资源构建阶段无法处理 Swift 文件
- python - 复制 S3 存储桶中嵌套文件夹中的文件
- oracle-adf - 在 jdeveloper 中运行 ant 时包 oracle.jbo.server 不存在
- matlab - 对齐直方图
- tabulator - 无法让 Tabulator 呈现表格版本 4