<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>Contacts Example</title>
<script type="text/javascript">
// 监听plusready事件
document.addEventListener( "plusready", function(){
// 扩展API加载完毕,现在可以正常调用扩展API
plus.contacts.getAddressBook( plus.contacts.ADDRESSBOOK_PHONE, function( addressbook ) {
// 向通讯录中添加联系人
var contact = addressbook.create();
contact.name = {givenName:"王安"};
contact.phoneNumbers = [{type:"手机",value:"88888888",preferred:true}];
contact.save( function () {
alert( "保存联系人成功" );
}, function ( e ) {
alert( "保存联系人失败:" + e.message );
} );
}, function ( e ) {
alert( "Get address book failed: " + e.message );
} );
}, false );
</script>
</head>
<body>
</body>
</html>
手机:红米2A
1 个回复
云飞狼舞 (作者)
问题解决了,代码没有毛病,刚更新了一下编辑器就能调试成功了,应该是老版本真机运行基座的问题!