我想从TypeScript中的字符串中删除单引号。我使用以下方法来实现这一目标。
var Id = this.currentId.replaceAll('"','');
var id = this.currentId.remove('\'', '');
尝试了以上方法。
预先感谢
答案 0 :(得分:0)
您可以使用String.prototype.replace查找和删除字符串中的所有单引号。
示例:
<StackLayout>
<!-- Place new controls here -->
<Image Source="botaocadastrolivre.png">
<Image.GestureRecognizers>
<TapGestureRecognizer
Tapped="OnTapGestureRecognizerTapped"
NumberOfTapsRequired="1" />
</Image.GestureRecognizers>
</Image>
</StackLayout>
void OnTapGestureRecognizerTapped(object sender, EventArgs args)
{
tapCount++;
var imageSender = (Image)sender;
// watch the monkey go from color to black&white!
if (tapCount % 2 == 0)
{
imageSender.Source = "botaocadastrolivre.png";
}
else
{
imageSender.Source = "botaocadastroPresed.png";
Navigation.PushAsync(new Nova());
}
// Task.Delay(100)
//Navigation.PushAsync(new Nova());
}