if语句数值比较判断正确却无法跳转怎么解决?

小程序 文章 2022-02-16 11:20 384 0 全屏看文

AI助手支持GPT4.0

if语句数值比较判断正确却无法跳转怎么解决?How to solve if statement value comparison is correct but cannot jump?

if语句数值比较判断正确却无法跳转怎么解决?

做登录页的时候判断用户名存在与否的语句,用的是“==”比较运算符,无论输入是否匹配,都显示“无此用户名”。

可以进行if语句判断并成功打印,(如果相等则打印)但一直无法往下走,直接else显示“无此用户名”,求解qwq。

ps:调用的是云数据库的内容,username是string类型。

When making the login page, the statement to judge whether the user name exists or not uses the "= =" comparison operator. No matter whether the input matches or not, it displays "no such user name". The if statement can be judged and printed successfully (if it is equal, it will be printed), but it can't go down. Else directly displays "no user name" and solves qwq. PS: the content of cloud database is called, and username is of string type.

回答:

青寒:

你可以断点或日志调试;

另外你这种循环里的判定方法,除非就1条符合的数据才不会弹窗,否则有其他不符合的都会弹吧。

解冬雪:不过昨晚调试的时候,可以正常走,不知道为什么今天就不行了。昨晚用的是= 赋值运算符,虽然不对 但却可以正常出现“”用户名存在和不存在的情况。今天把=改成==反倒不对了
解冬雪:

刚看别的帖子说 用fail(err) 就可以返回了?求解

brave:
adminlist.some(item => item.username === "20180001")
解冬雪:我试下!
八九:

修改下匹配方法,你用的for循环是这样的

解冬雪:是应该不用for循环吗

-EOF-

AI助手支持GPT4.0