<view>
<button @click="callPhone">拨打电话</button>
</view>
其实uni.makePhoneCall也可以实现小程序拨打电话的功能,都是官方API。直接用,很简单。
methods: {
callPhone() {
// #ifdef APP-PLUS
uni.makePhoneCall({
phoneNumber: 'xxx电话号码',
success: function() {
console.log("拨打电话成功!")
},
fail: function() {
console.log("拨打电话失败!")
}
})
// #endif
// #ifdef MP-WEIXIN
wx.makePhoneCall({
phoneNumber: 'xxx电话号码',
success: function() {
console.log("拨打电话成功!")
},
fail: function() {
console.log("拨打电话失败!")
}
})
// #endif
},
}