Blazor JS interop: call void functions (#12584)

pull/12588/head
Luke Latham 2019-05-29 12:58:52 -05:00 committed by GitHub
parent 5870e42ecb
commit 1d8cb18eb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -5,7 +5,7 @@ description: Learn how to invoke JavaScript functions from .NET and .NET methods
monikerRange: '>= aspnetcore-3.0'
ms.author: riande
ms.custom: mvc
ms.date: 05/21/2019
ms.date: 05/29/2019
uid: blazor/javascript-interop
---
# Blazor JavaScript interop
@ -101,6 +101,10 @@ The sample app includes a component to demonstrate JavaScript interop. The compo
1. The `showPrompt` function accepts user input (the user's name), which is HTML-encoded and returned to the component. The component stores the user's name in a local variable, `name`.
1. The string stored in `name` is incorporated into a welcome message, which is passed to a JavaScript function, `displayWelcome`, which renders the welcome message into a heading tag.
## Call a void JavaScript function
JavaScript functions that return [void(0)/void 0](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Operators/void) or [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined) are called with `IJSRuntime.InvokeAsync<object>`, which returns `null`.
## Detect when a Blazor app is prerendering
[!INCLUDE[](~/includes/blazor-prerendering.md)]