这是一个纯JavaScript文件。如何将我的客户变量设置为通话中返回的数据?
function test(columnName) {
var customers = [];
$pnp.sp.web.lists.getByTitle("Documents").fields.getByTitle(columnName).get().then(f => {
if (f.Choices) {
customers = f.Choices;
console.log(f.Choices);
}
});
使用承诺。
function test(columnName) {
return new Promise((resolve, reject) => {
$pnp.sp.web.lists.getByTitle("Documents").fields.getByTitle(columnName).get().then(f => {
if (f.Choices) {
resolve(f.Choices);
}
else {
reject("Nothing found.");
}
});
});
}