假设名为 cinput.cshtml 的子组件是
<input type="text" bind="@username">
@functions{
string username;
}
Run Code Online (Sandbox Code Playgroud)
和名为 pform.cshtml 的父组件
<cinput></cinput>
<input type="text" bind="@email">
<input type="button" onclick="@onsubmit">
@functions{
string email;
public void onsubmit(){
//Call api
}
}
Run Code Online (Sandbox Code Playgroud)
所以问题是如何在父组件中获取用户名值?