不能在 React 组件中使用 electron 的 webview 属性
Can't use electron's webview attributes in React component
给定一个像
这样的电子网络视图
<webview
minwidth="300"
minheight="300"
src="http://www.javascript-coder.com/files/window-popup/javascript-window-open-example1.html"
allowpopups
></webview>
直接在 app.html
中使用,效果如预期。
但是当我在 react-component 或只是 ReactDom.render 中使用它时,它会忽略除 src
之外的所有道具。所以弹出窗口不会在点击时打开:
import React from 'react';
import { render } from 'react-dom';
render(
<webview
minwidth="300"
minheight="300"
src="http://www.javascript-coder.com/files/window-popup/javascript-window-open-example1.html"
allowpopups
/>,
document.getElementById('root')
);
在我得到的开发工具中
Warning: Unknown props minwidth
, minheight
, allowpopups
on
tag. Remove these props from the element. For details, see
https://facebook.github.io/react/warnings/unknown-prop.html
提示:我用的是最新的https://github.com/chentsulin/electron-react-boilerplate
有什么想法吗?
您需要将 webview
元素包装在 React 组件中,并让组件创建元素并将其插入到 componentDidMount()
中的 DOM 中。有关详细信息,请参阅 this issue。
给定一个像
这样的电子网络视图<webview
minwidth="300"
minheight="300"
src="http://www.javascript-coder.com/files/window-popup/javascript-window-open-example1.html"
allowpopups
></webview>
直接在 app.html
中使用,效果如预期。
但是当我在 react-component 或只是 ReactDom.render 中使用它时,它会忽略除 src
之外的所有道具。所以弹出窗口不会在点击时打开:
import React from 'react';
import { render } from 'react-dom';
render(
<webview
minwidth="300"
minheight="300"
src="http://www.javascript-coder.com/files/window-popup/javascript-window-open-example1.html"
allowpopups
/>,
document.getElementById('root')
);
在我得到的开发工具中
Warning: Unknown props
minwidth
,minheight
,allowpopups
on tag. Remove these props from the element. For details, see https://facebook.github.io/react/warnings/unknown-prop.html
提示:我用的是最新的https://github.com/chentsulin/electron-react-boilerplate
有什么想法吗?
您需要将 webview
元素包装在 React 组件中,并让组件创建元素并将其插入到 componentDidMount()
中的 DOM 中。有关详细信息,请参阅 this issue。