热门

最新

红包

立Flag

投票

同城

我的

发布
weixin_45809580
前端呆头鹅
2 月前
trueweixin_45809580

怎样在手机端实现拨打电话功能呢?
<a :href="'tel:' +mobileNum" >打电话</a>

如何兼容PC端呢?如果PC端没有装载对应应用的话,可以弹窗提示电话号码手动拨打。
<a @click="phoneCallFun" :href="'tel:' +mobileNum" >打电话</a>


import { Dialog } from 'vant';
export function phoneCallFun(event: Event) {
const target = event.target as HTMLElement;
const phone = target.getAttribute('href')?.replace('tel:', '');
if (phone) {
event.preventDefault();
Dialog.confirm({
message: phone,
confirmButtonText: '确认',
showCancelButton: false,
})
}
}

每日学习打卡
CSDN App 扫码分享
分享
评论
点赞
打赏
  • 复制链接
  • 举报
下一条动态
立即登录