我正在尝试将text/html嵌入到react组件中。但是当我用电子运行我的应用程序时,谷歌检查员给我展示了一些错误。
Uncaught invariant.js:38不变体冲突:
style
支柱需要从样式属性到值的映射,而不是字符串。例如,在使用JSX时使用style={{marginRight: spacing + 'em'}}
。这个DOM节点由Example
呈现。
<object>
解决方案:用 <webview>
替换
这是我的密码
import React from 'react';
import SkyLight from 'react-skylight';
class Example extends React.Component {
constructor(props){
super(props);
}
render() {
return (
<div>
<section>
<h1>React SkyLight</h1>
<button onClick={() => this.refs.simpleDialog.show()}>Ouvrez le modal</button>
</section>
<SkyLight hideOnOverlayClicked ref="simpleDialog" title="Hi, I'm a simple modal">
<object type="text/html" data="http://www.example.com" style="width:100%; height:100%">
<p>backup content</p>
</object>
</SkyLight>
</div>
)
}
}
Example.displayName = 'Example';
export default Example;
发布于 2016-12-02 15:16:35
试着改变这一行
<object type="text/html" data="http://www.example.com" style="width:100%; height:100%">
有了这个
<object type="text/html" data="http://www.example.com"
style={{width:'100%', height:'100%'}}>
样式属性需要一个json对象,有关更多详细信息,您可以检查这个链接https://facebook.github.io/react/docs/dom-elements.html#style。
https://stackoverflow.com/questions/40934534
复制相似问题