草庐IT

ViewComponent

全部标签

c# - 有什么充分的理由不在核心 MVC 中使用 ViewComponent 而不是 Partial View 吗?

我是MVC的新手,决定从.net-core开始,所以我不太了解核心版本与旧版本之间的差异。我确实找到了下面的问题,它提供了一些见解,但并没有帮助我决定我是否可以基本上忽略部分观点。WhyshouldweuseMVC6FeatureViewComponentsoverPartialView:Whatisthedifference?我的问题很简单-如果我可以用ViewComponent做一些事情,有什么好的理由不这样做吗?非常感谢!下面提供了上下文示例。主视图调用:View组件:@awaitComponent.InvokeAsync("CreatePerson",newPerson())与

将文本框值从视图到viewComponent

我有一个称为视图组件的视图,并通过以下方式传递了称为konstant的模型:@foreach(KonstantiteminModel){@awaitComponent.InvokeAsync("MeterReader2",new{k=item})}如果我们查看视图组件,则看起来像这样:publicclassMeterReader2ViewComponent:ViewComponent{publicasyncTaskInvokeAsync(Models.Konstantk)//Endastenkanal.{//logic....}}到目前为止,这对我有用。但是,我的问题是,如何在视图中介绍两个文

ASP.NET Core-使用ResponseCache与ViewComponent

这是我的视图组件:publicclassCategories:ViewComponent{privatereadonlyICategoryService_categories;publicCategories(ICategoryServicecategories){_categories=categories;}publicIViewComponentResultInvoke(){varcat=_categories.GetCategories();returnView(viewName:"Default",model:cat);}}这是我在我看来使用它的方式:@awaitComponent.

ios - Swift:构建还是不构建

我终于从Objective-C转向了Swift。我正在为我的客户创建一个View布局系统,使他们的应用程序在布局上更加灵活,而不使用自动布局,因为他们想远程设计他们的屏幕,而自动布局对他们来说太复杂了。我尝试使用structs和protocols来做到这一点,但我发现它很笨拙,所以我怀疑我没有以正确的方式思考它。对于类,结构如下:classViewModel{varframe:CGRect=.zero}classViewGroupModel:ViewModel{varweight:Int=1varchildren:[ViewModel]=[ViewModel]()}classHoriz