You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/integrate-components.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Learn about data binding scenarios for components and DOM elements
5
5
monikerRange: '>= aspnetcore-3.1'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 03/17/2020
8
+
ms.date: 04/01/2020
9
9
no-loc: [Blazor, SignalR]
10
10
uid: blazor/integrate-components
11
11
---
@@ -105,6 +105,19 @@ To support routable Razor components in Razor Pages apps:
105
105
106
106
Components use the shared *_Layout.cshtml* file for their layout.
107
107
108
+
<xref:Microsoft.AspNetCore.Mvc.Rendering.RenderMode> configures whether the `App` component:
109
+
110
+
* Is prerendered into the page.
111
+
* Is rendered as static HTML on the page or if it includes the necessary information to bootstrap a Blazor app from the user agent.
112
+
113
+
| Render Mode | Description |
114
+
| ----------- | ----------- |
115
+
|<xref:Microsoft.AspNetCore.Mvc.Rendering.RenderMode.ServerPrerendered>| Renders the `App` component into static HTML and includes a marker for a Blazor Server app. When the user-agent starts, this marker is used to bootstrap a Blazor app. |
116
+
|<xref:Microsoft.AspNetCore.Mvc.Rendering.RenderMode.Server>| Renders a marker for a Blazor Server app. Output from the `App` component isn't included. When the user-agent starts, this marker is used to bootstrap a Blazor app. |
117
+
|<xref:Microsoft.AspNetCore.Mvc.Rendering.RenderMode.Static>| Renders the `App` component into static HTML. |
118
+
119
+
For more information on the Component Tag Helper, see <xref:mvc/views/tag-helpers/builtin-th/component-tag-helper>.
120
+
108
121
1. Add a low-priority route for the *_Host.cshtml* page to endpoint configuration in `Startup.Configure`:
@@ -14,12 +14,25 @@ By [Daniel Roth](https://github.com/danroth27) and [Luke Latham](https://github.
14
14
15
15
To render a component from a page or view, use the [Component Tag Helper](xref:Microsoft.AspNetCore.Mvc.TagHelpers.ComponentTagHelper).
16
16
17
+
## Prerequisites
18
+
19
+
Follow the guidance in the *Prepare the app to use components in pages and views* section of the <xref:blazor/integrate-components#prepare-the-app-to-use-components-in-pages-and-views> article.
20
+
21
+
## Component Tag Helper
22
+
17
23
The following Component Tag Helper renders the `Counter` component in a page or view:
The preceding example assumes that the `Counter` component is in the app's *Pages* folder.
35
+
23
36
The Component Tag Helper can also pass parameters to components. Consider the following `ColorfulCheckbox` component that sets the check box label's color and size:
24
37
25
38
```razor
@@ -51,10 +64,17 @@ The Component Tag Helper can also pass parameters to components. Consider the fo
51
64
The `Size` (`int`) and `Color` (`string`) [component parameters](xref:blazor/components#component-parameters) can be set by the Component Tag Helper:
The preceding example assumes that the `ColorfulCheckbox` component is in the app's *Shared* folder.
77
+
58
78
The following HTML is rendered in the page or view:
59
79
60
80
```html
@@ -68,6 +88,60 @@ Passing a quoted string requires an [explicit Razor expression](xref:mvc/views/r
68
88
69
89
The parameter type must be JSON serializable, which typically means that the type must have a default constructor and settable properties. For example, you can specify a value for `Size` and `Color` in the preceding example because the types of `Size` and `Color` are primitive types (`int` and `string`), which are supported by the JSON serializer.
70
90
91
+
In the following example, a class object is passed to the component:
The preceding example assumes that the `MyComponent` component is in the app's *Shared* folder. `MyClass` is in the app's namespace (`{APP ASSEMBLY}`).
144
+
71
145
<xref:Microsoft.AspNetCore.Mvc.Rendering.RenderMode> configures whether the component:
0 commit comments