在微信小程序中使用 wx.makePhoneCall API 来拨打电话
wx.makePhoneCall({
phoneNumber: '123456789',
success: function(res){
console.log(res)
},
fail: function(err){
console.log(err)
}
})
这个 API 需要一个 phoneNumber 参数,表示要拨打的电话号码。成功拨打电话后,会触发 success 回调函数,失败则会触发 fail 回调函数。
抖音小程序代码示例
<button type="default" size="default" bindtap="tapMakePhoneCall">拨打电话</button>
Page({
tapMakePhoneCall() {
tt.makePhoneCall({
phoneNumber: "18888888888", success(res){
// 调用成功 makePhoneCall:ok
console.log("调用成功", res.errMsg);
}, fail(res) { // 调用失败 makePhoneCall:fail
console.log("调用失败", res.errMsg);
},
});
},
});
转载于:http:///t/34
















