1:调用关键字function来构造 如: function distance(x1,x2,y1,y2) { var dx = x2 - x1; var dy = y2 - y1; return Math.sqrt(dx * dx + dy * dy); } 2:使用Function()构造函数 如: var f = new Function * " x " , " y " , " return x
/*1.方法调用模式: 先定义一个对象,然后在对象的属性中定义方法,通过myobject.property来执行方法,this即指当前的myobject 对象.*/ var car = { carId:123, carName:"奥迪", carColor:"red", say:function(){ console.log(this.carName+" color is "+this.carColor); } }; car.say(); /*2
doT.js特点是快,小,无依赖其他插件.但是一般和jquery一起使用 官网:http://olado.github.io 使用方法:{{= }} for interpolation{{ }} for evaluation{{~ }} for array iteration{{? }} for conditionals{{! }} for interpolation with encoding{{# }} for compile-time evaluation/includes and par
doT.js详细介绍 doT.js特点是快,小,无依赖其他插件. 官网:http://olado.github.iodoT.js详细使用介绍 使用方法:{{= }} for interpolation{{ }} for evaluation{{~ }} for array iteration{{? }} for conditionals{{! }} for interpolation with encoding{{# }} for compile-time evaluation/includ
dot.js是一个短小精悍的js模板引擎,压缩版仅有4K大小,最近使用dot的时候整理出这个dot.js教程文档,其实称不上什么教程,只是对dot.js的介绍和实例,希望能帮助到一部分需要的人. 使用方法: {{= }} for 赋值 {{ }} for evaluation {{~ }} for for循环数组 {{? }} for if判断 {{! }} for html标签是否转义 {{# }} for compile-time evaluation/includes and partia