knockout——官网demo
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="http://localhost:81/js/knockout.js"></script>
</head>
<body>
<span>1:<b data-bind="text:stringValue"></b></span><br>
<span>2:<b data-bind="text:passwordValue"></b></span><br>
<span>3:<b data-bind="text:booleanValue"></b></span><br>
<span>4:<b data-bind="text:boolean"></b></span><br>
<span>5:<b data-bind="text:selectedOptionValue"></b></span> <!---valueUpdate是可以实时更新的可选选项--->
<input data-bind="value:stringValue,valueUpdate: 'afterkeydown'">
<input data-bind="value:passwordValue,valueUpdate: 'afterkeydown'">
<input data-bind="value:booleanValue,valueUpdate: 'afterkeydown'">
<input type="checkbox" data-bind="checked: boolean">
<select data-bind="options: selectMutiple,value: 'selectedOptionValue'"></select>
<script>
var V = function(){
this.stringValue = ko.observable(0);
this.passwordValue = ko.observable(0);
this.booleanValue = ko.observable(0);
this.boolean = ko.observable(true);
this.selectMutiple = ["Alpha", "Beta", "Gamma"];
this.selectedOptionValue = ko.observable("Gamma")
};
ko.applyBindings(new V())
</script>
</body>
</html>
//demo2
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="http://localhost:81/js/knockout.js"></script>
</head>
<body>
<form data-bind="submit:addItem">
<input type="text" data-bind="value: item"/>
<button type="submit">submit</button>
<select multiple="multiple" data-bind="options: items"></select>
</form>
<script> var V = function(){
this.item = ko.observable("qihao");
this.addItem = function(){
if( !this.item() )return;
console.log(this.items)
this.items.push( this.item() )
}.bind(this);
this.items = ko.observableArray(["nono","super"]) //绑定的是数组
}; ko.applyBindings( new V );
</script>
</body>
</html>
//DEMO3
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>knockOut</title>
<script src="http://localhost:81/js/knockout.js"></script>
</head>
<body>
<!--
<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<h2>Hello, <span data-bind="text: fullName"> </span>!</h2>
-->
<br>
<!--
<h2>age is : <b data-bind="text: age"></b></h2>
<h2>age input : <input data-bind="value: cAge" /></h2>
--> <div>click<b data-bind="text: count"></b></div>
<div><button data-bind="click : addCount, disable: vis">inc</button></div>
<div data-bind="visible: vis"><button data-bind="click : reset">reset</button></div>
<script>
function V(){
this.count = ko.observable(0); this.addCount = function(){
this.count( this.count()+1 );
};
this.vis = ko.computed(function(){
return this.count()>3
},this);
this.reset = function(){
this.count(0)
};
}
ko.applyBindings( new V() )
/*
var ViewModel = function(first, last) {
this.firstName = ko.observable(first);
this.lastName = ko.observable(last); //只要在该作用域里面有字段发生改变,就重新计算该内容的值
this.fullName = ko.computed(function() {
return this.firstName() + " " + this.lastName();
}, this);
}; console.log( new ViewModel("Planet", "Earth") )
ko.applyBindings(new ViewModel("Planet", "Earth"));
*/
/*
var AgeBind = function(v){ this.cAge = ko.observable(v);
//这个是只要当前作用域的字段发生改变,就重新计算生成值
this.age = ko.computed(function(){
return this.cAge();
},this);
};
ko.applyBindings(new AgeBind("28"))
*/
</script>
</body>
</html>
knockout——官网demo的更多相关文章
- Java 银联支付官网demo测试及项目整合代码
注:原文来源与 < Java 银联支付官网demo测试及项目整合代码 > 银联支付(网关支付B2C) 一.测试官网demo a)下载官网开发包,导入eclipse等待修改(下载的开发包没 ...
- Knockout官网实例在MVC下的实现-02,实现计次
本篇使用Knockout在MVC下实现"Hello World",对应的官网实例在这里. 当次数达到3: View视图 页面包含三个部分:1.显示点击按钮的次数2.button按钮 ...
- Knockout官网实例在MVC下的实现-01,实现Hello world
本篇使用Knockout在MVC下实现"Hello World",对应的官网实例在这里. View视图 Knockout的一个特点是:声明式绑定,即Declarative bind ...
- jqgrid--api,官网demo,编辑
api参考: http://blog.csdn.net/hurryjiang/article/details/7551477 官网demo: http://www.trirand.com/blog/j ...
- webpack官网demo起步中遇到的问题
在webpack官网demo一开始搭建中
- Knockout 官网学习文档目录
官网:https://knockoutjs.com/documentation/introduction.html Knockout-Validation: https://github.com/Kn ...
- SpringBoot使用JSP(官网Demo)
最开始接触java的时候,前端页面基本都是用jsp来写,最近公司项目要使用SpringBoot重构,查看SpringBoot文档,发现SpringBoot不建议使用JSP,因为jsp在使用内嵌serv ...
- Knockout 官网翻译
Knockout 新版应用开发教程之创建view models与监控属性 章节导航 最近抽出点时间研究MVVM,包括司徒正美的avalon,google的angular,以及Knockout,博客园T ...
- 苹果官网 demo The Elements 阅读随笔
The Elements https://developer.apple.com/library/ios/samplecode/TheElements/Introduction/Intro.html# ...
随机推荐
- noip2014提高组day2二题题解-rLq
(又是昨天的作业……本题写于昨天) (这破题都做这么久,我是不是吃枣药丸……) (好吧这是一道图论题呢) 本题地址:http://www.luogu.org/problem/show?pid=2296 ...
- 怎么在ZBrush中通过遮罩得到子物体
ZBrush® 中通过遮罩为模型添加子物体的方法简单且方便,我们可以通过按住Ctrl键绘制遮罩结合相关命令创建具有抽出厚度的模型提取出作为子物体附在模型表面.本文将详细介绍在Zbrush中如何通过遮罩 ...
- 利用HttpListener创建简单的HTTP服务
using System; using System.Collections.Generic; using System.IO; using System.IO.Compression; using ...
- is A和has A的区别
is A has A Red is A Color: class Red extends Color{} class Blue extends Color{} class Yellow exrends ...
- 第23章 SEH结构化异常处理(3)_终止处理程序
23.3 终止处理程序 23.3.1 程序的结构 (1)框架 __try{ //被保护的代码块 …… } __finally{ //终止处理 } (2)__try/__finally的特点 ①fina ...
- Inspector a ProgressBar(定制属性面板)
一.定制进度条 这篇文章主要学习如何在Unity的Inspector中使用ProgressBar 普通属性面板预览 通常我们的属性面板如下 定制属性面板预览 而通过扩展成ProcessBar后 二.内 ...
- java 8-7 接口
1. 接口的特点: A:接口用关键字interface表示 interface 接口名 {} B:类实现接口用implements表示 class 类名 implements 接口名 {} C:接口不 ...
- windows组件
Wcript.shell是windows自带的组件 因为他过于强大 所以经常被黑客加以利用 他可以调用系统内核运行的dos基本命令 与此对应的还有三个危险组件 他们分别是 FSO shell.Appl ...
- 16进制色值转换成RGB
#51147f 转换成RGB ,5*16+1 ,1*16+4,7*16+15 #A9A9A9 转换成RGB ,A*16+9 ,A*16+9,A*16+9
- 【转】【C#】判断两个文件是否相同
使用System.security.Cryptography.HashAlgorithm类为每个文件生成一个哈希码,然后比较两个哈希码是否相同 该哈希算法为一个文件生成一个小的二进制“指纹”,从统计学 ...