GitHub: https://github.com/houfeng/mokithtml
Mokit 最初编写于 2012 年,是一个面向移动应用的前端 mvc 框架,v3 版本进行了大量的重构或重写,并尽量的保持了和以前版本相似的 API,
v3 是一个「极轻量」的 MVVM 框架,相较目前主流的相似的框架(react/vue/angular),mokit v3 更为「轻量」,但愿为开发人员提供多一种的选择。前端
HTML:vue
<div id="app"> <input type="text" m:model="name" /> <button m:on:tap="say(name)">click me</button> </div>
JavaScript:react
//启动应用 mokit({ element: document.getElementById('app'), data:function(){ return { name: '世界' }; }, say: function (name) { alert('hello '+ name); } }).start();
编写组件:git
//定义一个 hello 组件 var Hello = new mokit.Component({ template: '<button m:on:tap="say(name)" m:content></button>', properties: { name: null}, say: function (name) { alert('hello '+ name); } });
HTML:github
<div id="app"> <m:hello m:prop:name="name">click me</m:hello> </div>
JavaScript:mvc
//启动应用 mokit({ element: document.getElementById('app'), components:{ Hello: Hello } data:function(){ return { name: '世界' }; } }).start();