The blazor template has this:
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
I know what App
and HeadOutlet
are (they are covered in the docs).
What are RootComponents
generally?
Can I add my own components too? (What sort of components might those be?)
CodePudding user response:
What are RootComponents generally?
The Renderer needs a starting node for a RenderTree. That's the root component. A WASM application can have one or more. It's probably easier to demonstrate that describe.
Create a project from the WebAssembly template.
Here's a modified index.html. Notice the extra html Div
and Span
elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>BlazorApp1</title>
<base href="/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/app.css" rel="stylesheet" />
<link href="BlazorApp1.styles.css" rel="stylesheet" />
</head>
<body>
<div id="counter"></div>
<span id="useless"></span>
<div id="app">Loading...</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" >Reload</a>
<a >