使用双屏在VS中开发Blazor Razor组件 [英] Developing Blazor Razor component in VS with dual screens

查看:282
本文介绍了使用双屏在VS中开发Blazor Razor组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在具有双屏环境的Visual Studio中打开Razor组件.我希望在一个屏幕上有标记,在另一个屏幕上有@code {}部分.虽然MVC开发的标记通常在一个屏幕上,而JS在另一个屏幕上.切换到Blazor C#替代了JS,但我的想法仍然映射为从一个代码读取标记,而另一个代码为读取标记. 我们可以创建代码与标记分离但仍保持连接的组件吗?

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.

推荐答案

您可以在partial class后面使用代码:

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; }
}

这是3.1的未来,在3.1之前,您不能使用partial class被继承自Microsoft.AspNetCore.Components.ComponenBase

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; }
}


这篇关于使用双屏在VS中开发Blazor Razor组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆