Can you use a ViewComponent in a Blazor layout

我只是一个虾纸丫 提交于 2019-12-11 04:53:33

问题


Just trying Blazor for the first time. With the default blazor template, I added a ViewComponent call to the MainLayout.cshtml:

@await Component.InvokeAsync("HeaderComponent")

Intellisense shows await can only be used in an async method.

I tried the same in a Blazor view - same result. I use the component in an MVC app in the layout (i use vc:header-component there).

So I'm not sure if this is possible, or just a current Blazor or VS2019 limitation.


回答1:


No, you can't use ViewComponent in Blazor. And yes, this is a limitation, in the same sense you can't use ViewComponent in Angular.

Why do you need a partial view ? Is there any use case in Blazor that components cannot satisfy ?



来源:https://stackoverflow.com/questions/54710764/can-you-use-a-viewcomponent-in-a-blazor-layout

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