.Net Core Blazor 使用
路由配置: @page "/counter"
JS运行环境: @inject IJSRuntime JSRuntime;
@inject ClassName PropertyName 注册对象
```
@page "/counter"
@inject IJSRuntime JSRuntime;
<h1>Counter: @user.name</h1>
<p>Current count: @user.age</p>
<input type="text" name="name" @bind="user.age" />
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code
{
class mmmmm
{
public string name { get; set; }
public int age { get; set; }
}
mmmmm user = new mmmmm();
async void IncrementCount()
{
user.age++;
// 运行JS脚本
var value = await JSRuntime.InvokeAsync<string>("uAlert", user.age);
user.name = value;
}
}
```
```
function uAlert(val) {
console.log(val)
return val+"";
}
```
??
??
?? 回复 ??
未定义 回复 ??
?? 回复 ??