File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change 1
1
@using Microsoft .AspNetCore .Components
2
2
@inherits ComponentBase
3
+ @using Microsoft .JSInterop
4
+ @inject IJSRuntime jSRuntime
3
5
<div class =" my-component" >
4
6
This Blazor component is defined in the <strong >BlazorComponentSample</strong > package.
5
7
</div >
10
12
{
11
13
Task OnClick (UIMouseEventArgs args )
12
14
{
13
- return ExampleJsInterop .Prompt (" you clicked me" );
15
+ return ExampleJsInterop .Prompt (jSRuntime , " you clicked me" );
14
16
}
15
17
}
Original file line number Diff line number Diff line change
1
+ using Microsoft . AspNetCore . Components ;
1
2
using Microsoft . JSInterop ;
2
3
using System . Threading . Tasks ;
3
4
4
5
namespace BlazorComponentSample
5
6
{
6
7
public class ExampleJsInterop
7
8
{
8
- public static Task < string > Prompt ( string message )
9
+ public static Task < string > Prompt ( IJSRuntime jSRuntime , string message )
9
10
{
10
11
// Implemented in exampleJsInterop.js
11
- return JSRuntime . Current . InvokeAsync < string > (
12
+ return jSRuntime . InvokeAsync < string > (
12
13
"exampleJsFunctions.showPrompt" ,
13
14
message ) ;
14
15
}
You can’t perform that action at this time.
0 commit comments