在我的 main.js 檔案中,我撰寫了以下代碼:
const Contact = styled(NavLink)`
color: ${props => props.theme.text};
position: absolute;
top: 2rem;
right: calc(1rem 2vw);
text-decoration: none;
z-index: 1;
`
<Contact target="_blank" to={{pathname: "mailto:[email protected]"}}>
<motion.h2
whileHover={{scale:1.1}}
whileTap={{scale:0.9}}
>
它在本地主機上作業正常。但是,在我在 Github Pages 上部署網站后,通過單擊按鈕,我被重定向到 https://username.github.io/webpage/#/mailto:[email protected] 而不是 [email protected]
uj5u.com熱心網友回復:
來自 react-router 的 NavLink 旨在在 SPA 中路由。只需為此使用“a”標簽
<a href="mailto:[email protected]">Email</a>
或者你應該試試
<Contact target="_blank" to='#'
onClick={() => window.location = 'mailto:[email protected]'}
>
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/461486.html
標籤:javascript 反应 重定向 github页面
上一篇:Terraform資源已更改
下一篇:AssertionError:302!=200:無法檢索重定向頁面“/api/v2/app/nextdialog”:回應代碼為302(預期為200)
