自己新建一个w文件!引入插件cordova-plugin-contacts,接管onLoad事件 ,拷贝如下的代码 ,直接就可以答应通讯录中的名称和电话
Model.prototype.modelLoad = function(event){ alert("aaa") document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { var options = new ContactFindOptions(); options.filter = ""; options.multiple=true; var fields = ["displayName","phoneNumbers"]; navigator.contacts.find(fields, onSuccess, onError,options); } function onSuccess(contacts) { for (var i = 0; i < contacts.length; i++) { alert("Display Name = " + JSON.stringify(contacts[i])); alert("displayName = " + contacts[i].displayName); var phoneNumbers = contacts[i].phoneNumbers; for(var j = 0;j<phoneNumbers.length;j++) alert("phoneNumbers= " + phoneNumbers[j].value); } } function onError(contactError) { alert('onError!'); } };
另外参考其他用户的分享:http://bbs.wex5.com/forum.php?mod=viewthread&tid=121274
评一波