0
点赞
收藏
分享

微信扫一扫

如何调用UNIAPP拨打电话功能

回溯 2024-11-06 阅读 24

<template>

 <view>

   <button @click="callPhone('1234567891')">拨打电话</button>

 </view>

</template>


export default {

 methods: {

   callPhone(phoneNumber) {

     // 判断手机号是否为空

     if (phoneNumber) {

       // 调用拨打电话的API

       uni.makePhoneCall({

         phoneNumber: phoneNumber, // 电话号码

         success: function () {

           console.log('拨打电话成功');

         },

         fail: function () {

           console.log('拨打电话失败');

         }

       });

     } else {

       uni.showToast({

         title: '电话号码不能为空',

         icon: 'none'

       });

     }

   }

 }

}

举报

相关推荐

0 条评论