reactjs - 如何在反应中测试url查询字符串
问题描述
如何从下面的代码片段测试 this.props.location.search。
我收到以下错误:TypeError:无法读取未定义的属性“搜索”
export class myView extends React.Component {
componentDidMount() {
const values = queryString.parse(this.props.location.search);
}
});
我想测试变量值中存在的值。
解决方案
我使用了@Praveen Rao Chavan.G 的建议,https: //medium.com/@matthew.holman/testing-url-hash-query-with-jest-8165f26ab94e链接帮助解决了这个问题。
推荐阅读
- sql - 为什么 laravel eloquont 关系返回空数组
- php - php error_log 在本地环境中不起作用
- python - 有没有办法使用 REGEX 逐列检查?
- gitlab - Gitlab服务器关闭时的Gitlab Runners
- ios - iOS 应用程序在控制台显示时卡在启动屏幕:尝试为已有的场景句柄创建面包屑操作?
- python - 从开始日期和结束日期创建时间序列
- r - 如何在 R 中将 uiOutput 下载为 HTML 文档
- javascript - 如何在固定高度可滚动侧边栏上的链接上滚动和关注活动状态?
- java - 如何为 Java Web 应用程序优化谷歌浏览器
- javascript - 井字游戏不改变单元格