You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Titanium 11.1.1中调用scrollableView.currentPage时报错:TypeError: scrollableView.currentPage is not a function

Titanium 11.1.1中调用scrollableView.currentPage时报错:TypeError: scrollableView.currentPage is not a function

嘿,我刚看到你的问题啦,这个报错其实是个很容易踩的小误区~先看看你抛出的错误信息:

[ERROR] TiExceptionHandler: (main) [1347,45778] /ui/common/TabGroupAndr.js:823
[ERROR] TiExceptionHandler:         scrollableView.currentPage(2);
[ERROR] TiExceptionHandler:                        ^
[ERROR] TiExceptionHandler: TypeError: scrollableView.currentPage is not a function
[ERROR] TiExceptionHandler:     at View.<anonymous> (/ui/common/ApplicationTabGroup_Andr.js:823:24)
[ERROR] TiExceptionHandler:     at View.value (ti:/kroll.js:1604:27)
[ERROR] TiExceptionHandler:     at View.value (ti:/kroll.js:1661:27)

问题出在你写的scrollableView.currentPage(2)这一行——currentPage是ScrollableView的属性,不是可以调用的方法!你把它当成函数来调用,自然会触发“不是函数”的类型错误。

给你两种场景的正确写法:

  • 如果是想获取当前显示页面的索引,直接读取属性即可:
    const currentPageIndex = scrollableView.currentPage;
    
  • 如果是想切换到第3个页面(索引从0开始,所以2对应第三个),直接给属性赋值就行:
    scrollableView.currentPage = 2;
    

哦对了,在Titanium 11.1.1的定义里,ScrollableView的currentPage就是一个数值类型的属性,用来标记当前活跃页面的索引,所以完全不需要加括号调用哦。

备注:内容来源于stack exchange,提问作者user21856157

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 13:25:30