react a标签跳转问题
2020-07-18 04:24
3143 查看
react中, 当a标签需要跳转到动态获取的外部链接, 比如:
profile:{ "website":"www.xxx.com" }
<a href={profile.website} target="_blank" rel="noopener noreferrer"></a>
会跳转到新的标签页,但是地址会是localhost:3000/www.xxx.com,跳转不成功
应该加上http
<a href={“http://”+profile.website} target="_blank" // onClick={()=>window.location.href=`http://${profile.website}`} rel="noopener noreferrer"></a>
然后你会发现blank就会失效,会一直在当前页打开
最后
<a href={“http://”+profile.website} target="_blank" // onClick={()=>window.location.href=`http://${profile.website}`} rel="noopener noreferrer external"></a>
就ok了
相关文章推荐
- 试着用React写项目-利用react-router解决跳转路由等问题(二)
- mui中a标签跳转问题
- react-router-dom BrowserRouter 无法跳转问题
- A标签跳转问题
- react入门之路由----react-router的跳转问题
- 试着用React写项目-利用react-router解决跳转路由等问题(二)
- 遇到问题-----JS中设置window.location.href跳转无效(在a标签里或这form表单里)
- 【HTML】<a>标签href属性不跳转问题
- js模拟form表单提交数据, js模拟a标签点击跳转,避开使用window.open引起来的浏览器阻止问题
- a标签href带参数跳转在javascript中问题
- .NET CORE 页面中a标签的href的跳转问题
- html 中a标签的问题(无反应,跳转,调用方法)
- 如何解决win10自带microsoft edge出现打不开标签页、打开标签页后闪退、新建标签页后卡死、页面跳转后打不开新页面并且原页面自己重复刷新等问题
- jQuery Mobile使用a标签跳转问题
- 关于对a标签使用了AJAX后页面还是跳转到连接页面的问题
- 解决a标签中的href="#"跳转到首页问题
- a标签onclick事件跳转失败问题
- 试着用React写项目-利用react-router解决跳转路由等问题(四)
- 解决IE6下a标签的onclick事件里的超链接不跳转问题
- 试着用React写项目-利用react-router解决跳转路由等问题(三)