代码:
public async void GetDoc()
{
HttpClient client = new HttpClient();
var randDoc = await mfunsAPI.GetRandDoc(10);
StackLayout stack = Content as StackLayout;
for (int i = 0; i < randDoc.Length; i++)
{
var Doc = JsonDocument.Parse(randDoc[i]).RootElement;
Button button = new Button { Text = Doc.GetProperty("id").GetInt32().ToString()};
int id = Doc.GetProperty("id").GetInt32();
button.Clicked += async (sender, args) => await GoToDoc(id);
stack.Children.Add(button);
Content = stack;
}
//上面那个for循环结束报错
}
所有代码里都没有出现过json这个变量,太奇怪了