你能试试吗
//load the sp.js script and execute the init method
//no guarantee sp.js will be fully loaded before init() runs.
SP.SOD.executeFunc('sp.js', init());
function init(){
//ensure script is fully loaded, then execute retrieveListItems()
ExecuteOrDelayUntilScriptLoaded(retrieveListItems(), 'sp.js');
}
或者,
SP.SOD.executeFunc('sp.js', null, function(){
ExecuteOrDelayUntilScriptLoaded(retrieveListItems(), 'sp.js');
});
ExecuteOrDelayUntilScriptLoaded
将等待“sp.js”文件完成加载,然后调用
retrieveListItems()
. 但如果没有请求sp.js,它将永远等待。这就是我们打电话的原因
executeFunc
首先请求“sp.js”。然而,它不能保证在继续之前已经加载。它只是将其添加到需要加载的脚本堆栈中,然后运行回调。