React设置IFRAME SRC从按钮单击
尝试设置将将URL末端更改为“ Light”或“ Dark”并刷新iframe的按钮或切换开关
const url = ("http://localhost/ij3&theme=")
const mode = ['light', 'dark']
const TestPage = () => (
<Card>
<Switch defaultChecked />
<Button
onClick={() => { }}
label="dark">
</Button>
<IframeResizer
src={url + mode}
style={{ width: '1px', width: '100%'}}
/>
</Card>
);
export default TestPage;
Trying to set a button or toggle switch that will alter end of the url to "light" or "dark" and refresh the iframe
const url = ("http://localhost/ij3&theme=")
const mode = ['light', 'dark']
const TestPage = () => (
<Card>
<Switch defaultChecked />
<Button
onClick={() => { }}
label="dark">
</Button>
<IframeResizer
src={url + mode}
style={{ width: '1px', width: '100%'}}
/>
</Card>
);
export default TestPage;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使
模式
作为react中的状态,因此每当会更改时,重新渲染时也将更新iframe srcmake
mode
as state in react so whenever it will change, on re-render it will also update the iframe src