Created
December 17, 2019 14:44
-
-
Save sugimomoto/ef2a779f702cd3c0de849e4040b85a53 to your computer and use it in GitHub Desktop.
key directive test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "/" | |
@using System.Collections.Generic; | |
<h1>Hello, world!</h1> | |
Welcome to your new app. | |
<table> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Age</th> | |
</tr> | |
</thead> | |
<tbody> | |
@foreach (var person in People) | |
{ | |
<tr @key="person"> | |
<td><input type="text" @bind-value="person.name" /></td> | |
<td><input type="text" @bind-value="person.age" /></td> | |
</tr> | |
} | |
</tbody> | |
</table> | |
<table> | |
<thead> | |
<tr> | |
<th>Name</th> | |
<th>Age</th> | |
</tr> | |
</thead> | |
<tbody> | |
@foreach (var person in People) | |
{ | |
<tr @key="person"> | |
<td><input type="text" @bind-value="person.name" /></td> | |
<td><input type="text" @bind-value="person.age" /></td> | |
</tr> | |
} | |
</tbody> | |
</table> | |
@code { | |
[Parameter] | |
public List<Person> People { get; set; } | |
protected override void OnInitialized() | |
{ | |
this.People = new List<Person>(); | |
People.Add(new Person() { name = "kazuya", age = 31 }); | |
People.Add(new Person() { name = "takahashi", age = 32 }); | |
} | |
public class Person | |
{ | |
public string name { get; set; } | |
public int age { get; set; } | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment