【发布时间】:2021-12-23 07:58:32
【问题描述】:
我需要将 google 表单集成到我的 gatsby 应用程序中。在 onsubmit 中,我打开了 google 表单。在提交表单后填写表单详细信息后,我需要将用户带到主页。我尝试使用 useNavigate 和 history 我无法将页面导航到主页。谁能指导我如何实现这一目标。提前致谢。
function GoogleLink() {
let navigate = useNavigate()
let openFrame = () => {
let iframe = document.createElement("iframe")
iframe.src = `googleform link`
iframe.frameBorder = "0"
iframe.id = "iframe"
iframe.style.position = "absolute"
iframe.style.zIndex = "999"
iframe.style.height = "100%"
iframe.style.width = "100%"
iframe.style.top = "0"
iframe.style.backgroundColor = "white"
iframe.style.border = "none"
document.body.prepend(iframe)
document.body.style.overflow = "hidden"
}
const handleSubmit = () => {
openFrame()
navigate("/home")
}
return (
<Layout>
<div>
<Row>
<Col>
<Button onClick={handleSubmit}>Click Here</Button>
</Col>
</Row>
</div>
</Layout>
)
}
【问题讨论】:
标签: reactjs google-forms