Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在实施 SharePoint Online 加载项 我需要数据SP.CamlQuery.createAllItemsQuery(),但是SP.CamlQueryundefined
SP.CamlQuery.createAllItemsQuery()
SP.CamlQuery
undefined
SP.CamlQuery在中定义,sp.js但您的代码在sp.js未加载时运行。因此,要克服这种使用SP.SOD.executeFunc来延迟代码的执行,直到sp.js加载。
sp.js
SP.SOD.executeFunc
注意:两者都有SP命名空间,但SP.SOD.executeFunc在文件中定义,core.js并且总是在 SharePoint 中加载。
SP
core.js
代码:
SP.SOD.executeFunc('sp.js', SP.ClientContext, function() { // do stuff, use SP.CamlQuery object });