uniapp点击拨打电话号码功能实现(app端/小程序)

<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
			},
}

猜你喜欢

转载自blog.csdn.net/m0_58665272/article/details/139793187