gpt4 book ai didi

javascript - MVC中的模型可以做计算吗

转载 作者:行者123 更新时间:2023-11-30 20:54:18 24 4
gpt4 key购买 nike

<分区>

例如,这是否适合模型:

var Model = function Model(){
this.chapterIndex = 0;
this.pageIndex = 0;
this.next = true;
this.prev = false;
this.getCurrentpage = function getCurrentPage(){
return chapterList[this.chapterIndex].pages[this.pageIndex];
};
this.getChapterPageLength = function getChapterPageLength(){
return chapterList[this.chapterIndex].pages.length;
};
this.getTotalChapters = function getTotalChapters(){
return chapterList.length;
};
this.canGoForwardInChapters = function canGoForwardInChapters(){
return this.chapterIndex + 1 < this.getTotalChapters();
};

或者应该在 Controller 中处理像 cangoForwardInChapters 这样的函数?

什么是最佳实践?

我读了https://www.sitepoint.com/mvc-design-pattern-javascript/作为引导我来到这里的引用。

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com