效果图:
1、H5页面----手机号写死:
<!-- #ifdef H5 --> <a href="tel:10086">h5平台下拨打</a> <!-- #endif -->
2、H5页面----动态获取手机号拨打:
<view><a :href="'tel:' + phone">拨打</a></view>
data() {return {phone: ''}},
APP:
<view @click="boda"><!-- #ifdef APP-PLUS --><text>{{phone}}</text><!-- #endif --><!-- #ifdef H5 --><a :href='phones'>{{phone}}</a><!-- #endif --></view>
小程序:
<view class="make-phone" @click="makePhone">{{phone}}</view>
methods:
<script>export default {data() {return {phone: '',phones: '',}}, onShow() { //H5this.phones = 'tel:' + 10086}, methods: {boda() {//或者 wx.makePhoneCall({uni.makePhoneCall({phoneNumber: this.phonesuccess: function() {console.log("拨打电话成功!")},fail: function() {console.log("拨打电话失败!")}});},makePhone() {wx.makePhoneCall({phoneNumber: this.phonesuccess: function() {console.log("拨打电话成功!")},fail: function() {console.log("拨打电话失败!")}});},}}</script>
来源地址:https://blog.csdn.net/maoge_666/article/details/130103453