0

我需要创建一个简单的类似计数器。我在 View 类中写的这个问题的解决方案。但我不明白如何将我的代码分成三部分 - 模型、视图、控制器。

class View {
   constructor(model) {
            this.count = 0;
    
            this.renderInitialTodoForm();
    
            this.likeButton.addEventListener('click', () => {
                this.count++;
                this.likeCount.innerHTML = this.count;
            })
    
        }
    
        renderInitialTodoForm = () => {
            this.app = this.getElement('#root');
    
            this.likeButton = this.createElement('span');
            this.likeButton.textContent = '';
            this.likeButton.classList.add('like')
    
            this.likeCount = this.createElement('span');
            this.likeCount.textContent = 0;
    
    
            this.app.append(this.likeButton, this.likeCount);
        };
}
4

0 回答 0