UNPKG

zero-mvc

Version:

zeromvc是一种mvc设计模式。主要意义在于分离视图代码、逻辑代码和数据处理代码。

36 lines 1 kB
// import { Control, Model, View, Zeromvc } from "." // export class TestModel extends Model { // MaxHp: number = 100 // hp: number = 100 // test(value: number) { // console.log(this) // this.hp -= value // } // } // export class TestView { // view: View = new View() // model = this.view.getModel(TestModel) // constructor() { // this.view.bind(this.model, this) // this.view.show() // this.view.emit("behurt", 5) // } // hp() { // console.log(this.model.hp) // } // } // export class TestControl extends Control { // model = this.getModel(TestModel) // constructor() { // super() // this.on("behurt", (value) => { // console.log("TestView发生behurt事件,参数为" + value) // // this.model.hp -= value // console.log(this.model) // this.model.test(value) // }) // } // } // new Zeromvc() // new TestControl() // new TestView()