How to use TagHelpers in Blazor?

巧了我就是萌 提交于 2019-12-10 16:39:19

问题


I created a tag helper and wanted to use that in my Blazor sample project. However, when I want to use the tag helper, the compiler complains about that:

CS0103 The name 'StartTagHelperWritingScope' does not exist in the current context FirstBlazorApp.

What is additionally required to make tag helpers work in Blazor?


回答1:


Tag helpers are not supported in Blazor. At least not as of now.




回答2:


On A blazor page you would use a blazor component, this is like a TagHelper but it runs client side and is like an Angular component (or similar in any other client side JS framework) is that respect. TagHelpers run on the Server and blazor components run on the client, both allow you to create new tags. a simple component in the blazor same is the NavMenu which lives currently in the Shared folder.




回答3:


I know this is an old question but I just discovered you can use Partial Components inside of Razor Components. So if you want to use tag helpers, move the elements that need them to a partial and include it in the Razor Component.



来源:https://stackoverflow.com/questions/49389975/how-to-use-taghelpers-in-blazor

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