我正在寻找一种在 View 组件中调用 Model binder 的方法。我更喜欢使用来自 asp.net core 的内置功能,但这仅在 Controller 内部可用,而不是 View Components 本身。有什么办法可以解决这个问题?
最佳答案
根据 View Components文档:
View Components don’t use model binding, and only depend on the data you provide when calling into it.
但是,您可以将模型作为对象/参数传递到您的 ViewComponent 中:
@await Component.InvokeAsync("PriorityList", MyModel)
或
@await Component.InvokeAsync("PriorityList", new { maxPriority = 2, isDone = false })
你想达到什么目的?
关于c# - Asp.net core View 组件模型绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36622098/