2***@qq.com
2***@qq.com
  • 发布:2024-03-17 20:35
  • 更新:2024-03-17 20:36
  • 阅读:97

【报Bug】uts向js暴露函数和类,函数和类方法都有默认参数,无参调用函数正常,类方法报错

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 家庭中文版

HBuilderX类型: 正式

HBuilderX版本号: 3.99

手机系统: Android

手机系统版本号: Android 13

手机厂商: 华为

手机机型: 荣耀v30

页面类型: vue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

index.uts代码

export function test(p:string = "test"):void{  
    console.log(p);  
}  

export class Text{  
    constructor(){  

    }  
    classtest(p:string = "classtest"):void{  
        console.log(p);  
    }  
}

js代码,调用test函数是正常的,调用类方法classtest()会报“Error: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1”

import { TTS , test,Text} from "@/uni_modules/ns-tts"  
test()  
new Text().classtest()

操作步骤:

index.uts代码

export function test(p:string = "test"):void{  
    console.log(p);  
}  

export class Text{  
    constructor(){  

    }  
    classtest(p:string = "classtest"):void{  
        console.log(p);  
    }  
}

js代码,调用test函数是正常的,调用类方法classtest()会报“Error: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1”错误

import { TTS , test,Text} from "@/uni_modules/ns-tts"  
test()  
new Text().classtest()

预期结果:

分别打印出“test”,“classtest”两个字符串

实际结果:

打印出“test”,接着就报错“Error: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1”

bug描述:

2024-03-17 20:35 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者)

一般来说,函数和类方法是差不多的,这差异有点大了

要回复问题请先登录注册