问题描述
我在 react-native 中使用 expo-contacts 来获取联系方式。我刚刚开始并复制粘贴了用于这样做的代码。一切正常,但我不明白传递给 Contacts.getContactsAsync({pageSize: 1,offset: 0,fields: ['PHONE_NUMBER']})
的参数。
请解释pageSize
(我有点理解。我认为pageSize用于获取特定数量的联系人)、offset
和fields
(我认为fields
是一种过滤方法,但不确定)。
解决方法
哦,在问这个问题几分钟后,现在我明白了。
这里是详细信息;
fields >> If available the fields defined will be returned. If nil then all fields will be returned.
pageSize >> The max number of contacts to return. If nil or 0 then all contacts will be returned.
offset >> The number of contacts to skip before gathering contacts.
这里有更多细节;
https://docs.expo.io/versions/latest/sdk/contacts/#contactquery