We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<label>我是输入的值</label><input id="inp" type="text" name=""> <label>我是监听到的值</label><SPAN id="sp">- - -</SPAN> <script type="text/javascript"> var inp = document.getElementById("inp"); var sp = document.getElementById("sp"); inp.oninput = function() { console.log(this.value); sp.innerHTML = this.value; } </script>
<label>我是输入的值</label><input id="inp" type="text" name=""> <label>我是监听到的值</label><SPAN id="sp">- - -</SPAN> <script type="text/javascript"> var inp = document.getElementById("inp"); var sp = document.getElementById("sp"); // Controller : 用于存放业务逻辑 var Controller = { cinput: function(e) { // 往模型上放 Model.date = e.target.value; // 往模型上取,两者完全脱离联系 sp.innerHTML = Model.date; } }; // View : 用于添加事件 var View = { event: function() { inp.oninput = Controller.cinput; } }; // Model : 用于存放数据 var Model = { data:"" } // 初始化事件 View.event(); </script>
它们分别是Model(模型)、View(视图)和Controller(控制器)
就如机器一样,我们能接触到的只有开关,里面内部的逻辑我们无法改变,但是可以通过开关调节
View 传送指令到 Controller Controller 完成业务逻辑后,要求 Model 改变状态 Model 将新的数据发送到 View,用户得到反馈
所有的通信都是单向的
The text was updated successfully, but these errors were encountered:
No branches or pull requests
MVC-DEMO
逻辑介绍
传统写法
MVC写法
浅谈MVC
以微波炉为例子
模块间通信逻辑
所有的通信都是单向的
The text was updated successfully, but these errors were encountered: