uni-app 实现用户点击后自动拨打指定电话号码

uni 内部提供了一个makePhoneCall函数
那我们就直接看代码

<template>
	<view @click = "phone">13510657575</view>
</template>

<script>
	export default {
      
      
		data() {
      
      
			return {
      
      
			}
		},
		onLoad() {
      
      
	
		},
		methods: {
      
      
	        phone() {
      
      
				uni.makePhoneCall({
      
      
					phoneNumber: '1351-065-7575'
				})
			}
		}
	}
</script>

<style>
</style>

简单说 用户点击元素时 自动触发phone函数 phone里调用了uni内置的makePhoneCall函数 参数是一个对象 phoneNumber对应的就是要拨打的电话
用户点击效果如下
在这里插入图片描述
在这里插入图片描述
在手机中运行就会体现出更好的效果

猜你喜欢

转载自blog.csdn.net/weixin_45966674/article/details/125035321