Javascript 如何在react组件中嵌入text/html?

Javascript 如何在react组件中嵌入text/html?,javascript,html,reactjs,Javascript,Html,Reactjs,我正在尝试将text/html嵌入到react模式组件中。但是当我用electron运行我的应用程序时,Google Inspector显示了一些错误 Uncaught invariant.js:38 Uncaught invariant违例:styleprop需要从样式属性到值的映射,而不是字符串。例如,当使用JSX时,style={{{marginRight:spating+'em'}}。此DOM节点由示例呈现 解决方案:将替换为 这是我的密码 import React from 'reac

我正在尝试将text/html嵌入到react模式组件中。但是当我用electron运行我的应用程序时,Google Inspector显示了一些错误

Uncaught invariant.js:38 Uncaught invariant违例:
style
prop需要从样式属性到值的映射,而不是字符串。例如,当使用JSX时,
style={{{marginRight:spating+'em'}}
。此DOM节点由
示例
呈现

解决方案:将
替换为

这是我的密码

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;
从“React”导入React;
从“反应天窗”导入天窗;
类示例扩展了React.Component{
建造师(道具){
超级(道具);
}
render(){
返回(
反应天窗
this.refs.simpleDialog.show()}>Ouvrez-le-modal
备份内容

) } } Example.displayName='Example'; 导出默认示例;
尝试更改此行

<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%'}}>


style属性需要一个json对象,有关更多详细信息,您可以查看此链接

它可以正常工作,但由于“https”站点的跨域安全,因此出现问题。错误“在一个框架中,因为它将“X-frame-Options”设置为“SAMEORIGIN”。”该错误意味着主机禁止您将其页面放入iframe/对象中。您将无法完成您正在尝试的操作,至少在该特定站点上是这样。不过,对于其他网站/页面来说,它可能工作得很好。更多信息请访问: