前端项目设置点击手机号码唤起拨号功能

364 阅读1分钟
方法一:利用a标签的href属性
<!-- 直接利用a标签的hre -->
<a href="tel:4123456789">拨号</a>

方法二:使用window.location.href

1. 需要在index.html中添加如下代码

<meta name="format-detection" content="telephone=yes" />

2. 调用拨号功能

callPhone (phoneNumber) {
    window.location.href = 'tel:' + phoneNumber
}