SharePoint 2016:错误:get_count()不是函数 [英] SharePoint 2016: Error: get_count() is not a function
本文介绍了SharePoint 2016:错误:get_count()不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将我的SharePoint 2013发布网站代码转换为SharePoint 2016.
I am trying to convert my SharePoint 2013 publishing site code to SharePoint 2016.
我有以下代码,当前在SharePoint 2016中不起作用:
I have the below code, which is currently not working in SharePoint 2016:
var selecteddownImg = "";
var selCategory = "abc";
function InvokeOne() {
var clientcontext = new SP.ClientContext.get_current();
var oweb = clientcontext.get_site().get_rootWeb();
var olibrary = oweb.get_lists().getByTitle(myLibrary);
var query = new SP.CamlQuery();
query.set_viewXml('<View><Query><Where><Eq><FieldRef Name=\'BCategory\'/>' +
'<Value Type=\'Choice\'>' + selCategory + '</Value></Eq></Where></Query></View>');
selecteddownImg = olibrary.getItems(query);
clientcontext.load(selecteddownImg);
clientcontext.executeQueryAsync(Function.createDelegate(this, this.onRequestSucceeded), Function.createDelegate(this, this.onRequestFailed));
}
function onRequestSucceeded() {
var templatescount = this.selecteddownImg.get_count();
}
我收到以下错误消息:
Uncaught TypeError: this.selecteddownImg.get_count is not a function at onRequestSucceeded
该如何解决?
谢谢
推荐答案
你好
尝试在不带"this"的情况下访问selecteddownImg变量.并使用null而不是string ::
try to access selecteddownImg variable without "this.". And initialize it with null, not with string::
var selecteddownImg = null;
...
function onRequestSucceeded() {
var templatescount = selecteddownImg.get_count();
}
这篇关于SharePoint 2016:错误:get_count()不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文