在需要点击拨打电话的标签上绑定一个点击事件bindtap,代码:
<view class="call" bindtap="makeCall">拨打电话</view>
在点击事件的方法里使用wx.makePhoneCall
Page({
data: {
phone:'400 888 8888',
},
makeCall:function(){
wx.makePhoneCall({
phoneNumber:this.data.phone
//或者直接phoneNumber:'400 888 8888'
})
}
})
官方文档:https://developers.weixin.qq.com/miniprogram/dev/api/device/phone/wx.makePhoneCall.html