我收到的错误:
此条件将始终返回'true‘,因为类型'string’和'number‘没有重叠。
代码:
if (this.$route.params.groupId != this.group.id) {
more code here
}'1‘!= 1(将返回false)
“%1”!== %1(将返回true)
它不会总是返回true
发布于 2021-09-17 04:40:53
我认为您澄清了为什么typescript显示错误(来自typescript显示错误消息) https://github.com/microsoft/TypeScript/issues/26592
在我看来,我们可以确定变量的类型,以便正确地进行比较
use `===` or `!==` to compare valueDetermine of type variable
const routeGroupId: string = this.$route.params.groupId;
const currentGroupId: string = this.group.id;
if(routeGroupId != currentGroupId)https://stackoverflow.com/questions/69213748
复制相似问题