[]为什么字符串不能连接?
private getRandomColor():String
{
let arr:Array<String>=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
let str:String="#";
for(let i:number=0;i<6;i++){
let index:number=arr.length*Math.random();
str+=arr[index];//在IDE里面这句报错 [ts] Operator '+' cannot be applied to types 'String' and 'String'.
}
return str;
}
{
let arr:Array<String>=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
let str:String="#";
for(let i:number=0;i<6;i++){
let index:number=arr.length*Math.random();
str+=arr[index];//在IDE里面这句报错 [ts] Operator '+' cannot be applied to types 'String' and 'String'.
}
return str;
}
没有找到相关结果
已邀请:
要回复问题请先登录
3 个回复
Laya_XS
赞同来自:
private getRandomColor():string
{
let arr:Array<String>=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
let str:string="#";
for(let i:number=0;i<6;i++){
let index:number=arr.length*Math.random();
str += arr[index];//在IDE里面这句报错 [ts] Operator '+' cannot be applied to types 'String' and 'String'.
}
return str;
}
Laya_XS
赞同来自:
Laya_XS
赞同来自: