Developing Blazor Razor component in VS with dual screens

只愿长相守 提交于 2020-01-29 23:31:30

问题


Is there a way to open Razor component in Visual Studio with environment with dual screens . I'll love to have markup on one screen and @code {} section on other. While MVC developing usually markup is on one screen while JS is on other. Switching to Blazor C# replaces JS,But my mind is still mapped to read markup from one while is code on other. Can we create component with code separated from markp but still connected.


回答1:


You can use the code behind with a partial class :

MyComponent.razor

<h1>Thi is a component @Title</h1>

MyComponent.razor.cs

public partial class MyComponent
{
      [Parameter]
      public string Title { get; set; }
}

This is a 3.1 future, before 3.1 you cannot use partial class be inherits from class deriving from Microsoft.AspNetCore.Components.ComponenBase

before 3.1

MyComponent.razor

@inherits MyComponentModel
<h1>Thi is a component @Title</h1>

MyComponent.razor.cs

using Microsoft.AspNetCore.Components;

public class MyComponentModel : ComponentBase
{
      [Parameter]
      public string Title { get; set; }
}




来源:https://stackoverflow.com/questions/59770358/developing-blazor-razor-component-in-vs-with-dual-screens

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!