<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="text" id="type"></input>
<p id="p"></p>
<script>
var html={}
//m
html.model ={ content:{
"0":"你好",
"1":"ok",
"2":"大家好",
"3":"你好",
"4":"ok",
"5":"大家好"
},
data:function(id){
if(!(id in this.content)){
var id = 0;
}
return this.content[id]
}
}
//v
html.view={
init:function(value){
document.getElementById("p").innerHTML= value;
},
id:function(){
return document.getElementById("type").value;
}
}
//c
html.controller = { init:function(){
var id = html.view.id(); //获取id
var value = html.model.data(id); //通过id 过滤数据
html.view.init(value); //把数据加载到页面中
}
}
document.getElementById("type").onchange = html.controller.init;
</script>
</body>
</html>

MVCmoduleExample.html的更多相关文章

随机推荐

  1. 【Selenium专题】鼠标键盘事件

    引用包来自selenium-java-2.23.1.jar 调用以下代码时,需要引入actions类,以java为例: import org.openqa.selenium.interactions. ...

  2. nova scheduler filters 配置

    scheduler_driver = nova.scheduler.filter_scheduler.FilterScheduler scheduler_default_filters = Avail ...

  3. WebView 错误码整理

    在使用WebView中,我们不可避免的会接触到WebView加载失败的异常处理的需求,这时候,需要我们监听失败的方法也就是onReceivedError方法: public class CustomW ...

  4. nodejs从http升级到https(阿里云证书的使用)

    升级原因 1.各大搜索引擎中,https的网页的权重比一般的http的网页权重要高. 2.从用户体验的角度,一个老是被浏览器提醒该网页不可信的网页,总不会让用户感到安心 所以将网站从http升级为ht ...

  5. linux内核中GNU C __attribute__ 机制的实用

    很多东西,只看看是不行的,要想深入的去了解一个东西,一定要去不断地学习,实践,反思. 说白了就是要去打磨. 在linux中,最近遇到了这样一个定义: int board_usb_init(int in ...

  6. linux下应用程序性能剖分神器gprofiler-tools-安装和使用

    最近在摆弄算法的的优化,需要剖分一下算法的瓶颈,就找了一些代码剖分工具,其中 gprofileer-tools是很不错的工具,gperftools时google开源的一款C++性能分析分析工具,git ...

  7. 机器学习基石笔记:11 Linear Models for Classification

    一.二元分类的线性模型 线性分类.线性回归.逻辑回归: 可视化这三个线性模型的代价函数, SQR.SCE的值都是大于等于0/1的. 理论分析上界: 将回归应用于分类: 线性回归后的参数值常用于pla/ ...

  8. LeetCode:149_Max Points on a line | 寻找一条直线上最多点的数量 | Hard

    题目:Max Points on a line Given n points on a 2D plane, find the maximum number of points that lie on ...

  9. druid的关键参数+数据库连接池运行原理

      minEvictableIdleTimeMillis :连接保持空闲而不被驱逐的最长存活时间.(默认30分钟) Destory线程中如果检测到当前连接的最后活跃时间和当前时间的差值大于minEvi ...

  10. 调用 Https WebService 使用程序自动生成代理类

    1 商家提供的WebService接口:  https://ws.nciic.org.cn/nciic_ws/services/NciicServices?wsdl 2 在浏览器里打开这个地址,会显示 ...