Typescript 测试列表中特定字段的存在性

Typescript 测试列表中特定字段的存在性,typescript,sharepoint-online,spfx,Typescript,Sharepoint Online,Spfx,我试图验证一个列表是否有一个特定的字段列表,它会不断返回列表中所有现有的字段,我该如何使它工作?有没有更好的方法来实现我的目标 sp.web.lists.getByTitle("SliceBox").fields.select("Title","Body","Link","Picture","Visible").get() .then( (fields: any[]) => { console.log("> number of fields returned:

我试图验证一个列表是否有一个特定的字段列表,它会不断返回列表中所有现有的字段,我该如何使它工作?有没有更好的方法来实现我的目标

sp.web.lists.getByTitle("SliceBox").fields.select("Title","Body","Link","Picture","Visible").get()
    .then( (fields: any[]) => {
        console.log("> number of fields returned:", fields.length);

        fields.forEach(f => {
            console.log("> field:", f);
        })              
    })
    .catch( err => {
        console.log("> fields failure: ", err);
});

在上述场景中,我们必须使用“过滤器”

 sp.web.lists.getByTitle("SliceBox").fields.filter("((Title eq 'Title') or (Title eq 'Body'))").get()
我们可以包含更多的“或”用于更多过滤器。
当我们使用“select”时,它只返回该字段中选定的属性。也就是说,如果我们使用select'Title',它将只返回所有字段的'Title'属性

这个结论回答了我的问题!顺便说一句,答案和例子都很棒!谢谢