javascript - 无法导航到 href,url 只是丢失了参数
问题描述
我在 react 中有一个 a 标签,单击它时不会将我带到 href 它只是删除了 url 中的所有参数?例如。我在:http://localhost:6006/iframe.html?selectedKind=Survey&selectedStory=...etc。然后它把我带到http://localhost:6006/iframe.html?点击,而不是 google.com
我也尝试过在单击按钮时使用 window.open ,如果我正常执行 window.open ,那也是一样的。有任何想法吗?
exitUrl = 'https://www.google.com';
target = '_self';
作品
window.open(this.exitUrl, this.target);
不工作
<a href={this.exitUrl} target={this.target}>
<button onClick={() =>window.open(this.exitUrl, this.target)}
还尝试将锚点的 onclick 设置为相同,但仍然无法正常工作:
let anchor = document.getElementById('wtfisgoinon');
anchor.onclick = window.open(this.exitUrl, this.target);
解决方案
如果你想打开它,没有必要使用“目标”属性。
只需使用:
<a href={this.exitUrl}> Exit </a>
推荐阅读
- google-cloud-platform - 从 Google Cloud VM、NGinx、Docker Container 向 SMTP 服务器发送电子邮件
- python - 找出数据框列是否包含单词 python
- python - Python Selenium 键无法在浏览器中按 CTRL+F 搜索
- tinymce - 如何在 tinyMCE 中删除自动完成时的触发字符?
- liskov-substitution-principle - Liskov 规则 - 澄清
- java - LocalDate.now().toString() 的实际返回类型是什么
- android - Android WorkManager 随机触发 doWork 函数
- python - 添加上下文底图时忽略绘图限制
- android - 有效使用 AppOpsManager.OnOpNotedCallback
- react-native - 无法在具有高度的容器顶部放置图标