小编Fan*_*sbi的帖子

'String' 类型的索引签名只允许读取

cipher当我尝试更改指定索引处的字符串字符时,我从变量中收到此警告。

const emojis: string[] = [/* values */];

function revealOriginEmojis(cipher: string): string {
  for(let i = 0; i < cipher.length; i++){
    let index: number = emojis.indexOf(cipher[i]);

    cipher[i] = emojis[index];
  }

  return cipher;
}
Run Code Online (Sandbox Code Playgroud)

那么,我应该创建一个新的字符串变量还是任何更好的解决方案?非常感谢

typescript

7
推荐指数
1
解决办法
3623
查看次数

标签 统计

typescript ×1