简体   繁体   English

在 Blazor WASM 中测试的代码(让它不慢)

[英]Code to Test In Blazor WASM (make it NOT slow)

How can I faster test changes in Layout using Blazor?如何使用 Blazor 更快地测试布局更改?

I used to code websites in good old Apache+PHP+MySQL.我曾经用古老的 Apache+PHP+MySQL 编写网站代码。 and now I am starting with some development in Blazor.现在我开始在 Blazor 中进行一些开发。

But I find it difficult to work on the user interface.但是我发现在用户界面上工作很困难。 When I need to test a small change, for instance moving a entry in a web form from one row to another...当我需要测试一个小的更改时,例如将 web 表单中的条目从一行移动到另一行...

Blazor WASM development process: Blazor WASM开发流程:

  • Edit the code编辑代码
  • Shutdown the browser关闭浏览器
  • Recompile (Pray that it compiles...)重新编译(祈祷它编译...)
  • Wait for the webapp+API-App+Identity App to startup等待webapp+API-App+Identity App启动
  • Navigate to the page I am making layout on.导航到我正在进行布局的页面。

PHP+X Process PHP+X 进程

  • Edit the code编辑代码
  • Press F5按 F5

I wish for a similar experience.我希望有类似的经历。 How can I decrease the development code/test UI time when using Blazor?使用 Blazor 时如何减少开发代码/测试 UI 时间?

The simplest way to do interactive development is using dotnet watch run from a command prompt (I add a .cmd script to my projects to run this for the project).进行交互式开发的最简单方法是在命令提示符下使用dotnet watch run (我在我的项目中添加了一个.cmd脚本来为项目运行它)。 This will run the project and watch for changes to files, then re-compile the project.这将运行项目并观察文件的更改,然后重新编译项目。

On .NET 3.x Blazor you'll have to refresh the browser (F5).在 .NET 3.x Blazor 上,您必须刷新浏览器 (F5)。 On .NET 5 projects it does this automatically.在 .NET 5 项目上,它会自动执行此操作。

You may also want to read Rémi Bourgarel's Blog article on this, although I am not sure all his points are still valid if you're using .NET 5.您可能还想阅读Rémi Bourgarel 的博客文章,尽管如果您使用的是 .NET 5,我不确定他的所有观点是否仍然有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM