SuperMonster003 / AutoJs6

安卓平台 JavaScript 自动化工具 (Auto.js 二次开发项目)
https://docs.autojs6.com
Mozilla Public License 2.0
2.16k stars 656 forks source link

TypeError: text 是 string 而非函数 #173

Closed Xerzsh closed 7 months ago

Xerzsh commented 7 months ago
const date = new Date();
const hours = date.getHours();
const minutes = date.getMinutes();
const timeString = `${hours}:${minutes}`;
text(timeString).findOne().parent().click();

这令我困惑。timeString这个变量的类型不就是string吗?

sucutey commented 7 months ago

上面代码没错,错误不在这里

Xerzsh commented 7 months ago

上面代码没错,错误不在这里

Screenshot_2023-11-13-18-58-56-021_org autojs autojs6 微信图片_20231113191856

Xerzsh commented 7 months ago

上面代码没错,错误不在这里

解决了。应该是我在21行所声明的同名变量所致。谢谢您

sucutey commented 7 months ago

你把全局的text指向修改成字符串了,原本是text=function(){}