Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于我认为使用的模型:@model Navigation
是否可以使用别名以便我的代码:@Model.MyNameField 可以成为 @Navigation.MyNameField?
这纯粹是为了可读性。我也很好奇为什么这是不好的做法。
IIRC,Model名称是因为这是 View 类的属性的名称。如果您子类化View并添加一个新属性,它应该可以工作。
Model
View
例如
public NavigationModel Navigation { Get { return Model.Navigation; } }
然后你可以做@Navigation.Foo
@Navigation.Foo