使用 reactJs 动态创建 iframe

Dynamically create a iframe using reactJs

本文关键字:iframe 创建 动态 reactJs 使用      更新时间:2023-09-26

我想在单击按钮后动态创建iframe witch特定的url和className。我开始使用反应,我不知道该怎么做。

你不需要做任何特别的事情:

var Iframer = React.createClass({
    render: function() {
        return <iframe src="https://www.google.com" className="my-iframe" />
    }
})
React.render(<Iframer />, document.getElementById('container'));

小提琴:

https://jsfiddle.net/mt6dfw4d/1/