var ctx = new SP.ClientContext.ClientContext();//get_current(); this.web = ctx.get_web(); var list=this.web.get_lists().getByTitle("commendation");//对应列表名称 var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml("<View><Query><Where><Gt>" +"<FieldRef Name='Created' />" +"<Value Type='DateTime'>2008-01-1T00:00:00Z</Value>" + "</Gt></Where></Query></View>"); listItemCollection = list.getItems(camlQuery); ctx.executeQueryAsync(Function.createDelegate(this, this.onUpdate), Function.createDelegate(this, this.onFail));
代码是写在test.js中.并在主页的webpart(Content Editor)引用
要等 sp.js 加载完成的,initialize是你要执行的函数名
ExecuteOrDelayUntilScriptLoaded(initialize, "sp.js");