typescript 接口的新认识
interface 用于接收服务器的数据。
eg:
interface mmmmm {
x: string,
y: number,
z: number,
select: KnockoutObservable<boolean>
}
$.post(url + '/app.ashx',
ko.utils.stringifyJson( {x: '12', y: 1, z: 10 }),
function (response) {
var result = $.parseJSON(response);
alert('ok');
var mm = <mmmmm>result;
mm.select = ko.observable(false);
alert(mm.select());
});
不会在js中出现。
可扩展的对象,定义为接口。可在ts中使用。不会报错。
interface Element {
scaleX: number;
scaleY: number;
offsetHeight: number;
offsetTop: number;
style: CSSStyleDeclaration,
offsetWidth: number;
}
interface Window {
startY: number;
Transform: (el: Element) => void;
yhaoTouch: (el: any) => void;
isscroll: boolean;
}
最新文章
- 【WCF】终结点的监听地址
- jQuery中的map()方法
- Linq中查询List组合相同值数量大于1
- spring简单事务管理器
- MongoDB基本命令的使用
- 锋利的jQuery第2版学习笔记8~11章
- hdu 2256 Problem of Precision 构造整数 + 矩阵快速幂
- 教你利用iframe在网页中显示天气
- HelloGitHub.com 网站开源了
- [CodeForces10D]LCIS(最长公共上升子序列) - DP
- mongodb 创建更新语法
- Go语言为何说它优雅?-- Golang中的几个常用初始化设计
- Activity的Launch mode详解,A B C D的singleTask模式
- Python3红楼梦人名出现次数统计分析
- Git - 回滚与撤销
- js实现响应式瀑布流
- TensorFlow数据读取方式:Dataset API
- nodejs 监控代码变动实现ftp上传
- HDU 1710 Binary Tree Traversals (二叉树遍历)
- Python3.5 执行发邮件脚本失败【惑】==>;【搞定】