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

Testing the existence of specific fields from a list

我正在尝试验证列表是否具有特定的字段列表,它不断返回列表中的所有现有字段,我该如何使它起作用?有没有更好的方法来实现我正在尝试的目标?

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);
});

在上述情况下我们将不得不使用 'filter'

 sp.web.lists.getByTitle("SliceBox").fields.filter("((Title eq 'Title') or (Title eq 'Body'))").get()

我们可以包含更多 'or' 以获得更多过滤器。 当我们使用 'select' 时,它只会 return 该字段中的那些选定属性。意思是,如果我们使用 select('Title') 它只会 return 'Title' 属性 所有字段。