MVC 6引入了View组件,并表示它比局部视图更强大和灵活。那是替换部分视图吗?他们之间有什么区别呢?
解决方法
根据这个链接
https://docs.asp.net/en/latest/mvc/views/view-components
New to ASP.NET MVC 6,view components (VCs) are similar to partial views,but they are much more powerful. VCs include the same separation-of-concerns and testability benefits found between a controller and view. You can think of a VC as a mini-controller—it’s responsible for rendering a chunk rather than a whole response.
所以这只是增强部分视图,另一个区别是当您使用部分视图时,仍然依赖于控制器,而在View Component中您不需要控制器。所以有分离的关注。
有一个ASP.NET视图组件的详细信息。
http://www.tugberkugurlu.com/archive/exciting-things-about-asp-net-vnext-series-mvc-view-components