我目前正在使用 MVVM 模式处理 Kendo Mobile 项目,但在如何分离以下 Kendo 组件时遇到了困难:
- 模式模型
- 数据源
- 视图模型
- 看法
我正在使用 RequireJS 来帮助模块化我的 JavaScript,并希望尽可能地使事情解耦。我真的不知道在我的项目中将数据源放在哪里。以下文件夹结构是否合适?我专门使用 Web 服务调用来处理我的数据:
应用程序/
model/ (all the schema models js) dataSource/ (all the data sources with CRUD service calls js) viewModel/ (holds all the view models js) view/ (holds the init, beforeShow, show, afterShow functions of respective views js) library/ (public libraries like jquery, requirejs) common/ (utilities)
我不确定文件夹名称等,因为我读过的一些文章说模型包含数据源。我不认为这是正确的,但我对 MVVM 模式还很陌生。适当文件夹结构的任何帮助和建议都会有很大帮助!作为旁注,我觉得应该合并 view 和 viewModel 文件夹,但我不确定......