Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何以不同的方式设计Blazor组件_C#_Css_Components_Blazor - Fatal编程技术网

C# 如何以不同的方式设计Blazor组件

C# 如何以不同的方式设计Blazor组件,c#,css,components,blazor,C#,Css,Components,Blazor,假设我有组件。如何根据实现它的不同位置对其进行不同的样式设置 例如,这就是我想要做的(为了方便使用引导类): MyDocument.razor <div> This text below will be red.</div> <MyText class="text-danger" /> <div> This text below will be blue.</div> <MyText class="

假设我有组件
。如何根据实现它的不同位置对其进行不同的样式设置

例如,这就是我想要做的(为了方便使用引导类):

MyDocument.razor

<div> This text below will be red.</div>
<MyText class="text-danger" /> 

<div> This text below will be blue.</div>
<MyText class="text-info" />
<div @attributes="AdditionalAttributes">Some Cool Text</div>

@code {
 [Parameter(CaptureUnmatchedValues = true)]
 public Dictionary<string, object> AdditionalAttributes { get; set; }
}
<div> This text below will be red.</div>
<MyText class="text-danger" /> 

<div> This text below will be blue.</div>
<MyText class="text-info" />
下面的文本将为红色。
下面的文本将为蓝色。
这将输出以下内容
看看
MyText.razor

<div> This text below will be red.</div>
<MyText class="text-danger" /> 

<div> This text below will be blue.</div>
<MyText class="text-info" />
<div @attributes="AdditionalAttributes">Some Cool Text</div>

@code {
 [Parameter(CaptureUnmatchedValues = true)]
 public Dictionary<string, object> AdditionalAttributes { get; set; }
}
<div> This text below will be red.</div>
<MyText class="text-danger" /> 

<div> This text below will be blue.</div>
<MyText class="text-info" />