【问题标题】:How to navigate to home page after submitting the google form提交谷歌表单后如何导航到主页
【发布时间】: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


    【解决方案1】:

    只需检查主页的链接是否定义为/home,或者只需将其替换为/

    默认/路由到主页

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-25
      • 1970-01-01
      • 1970-01-01
      • 2019-12-10
      • 1970-01-01
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      相关资源
      最近更新 更多