uniapp 拨打电话封装组件

uniapp yekong 1369℃

uniapp微信小程序 开发,对拨打电话功能进行封装,因为电话号码需要是字符串,所以在传值时,需要先将参数转为字符串。

代码

<template>
	<view>
		<text @click="makePhoneCall">拨打电话</text>
	</view>
</template>

<script>
	export default {
		props: {
			phone: {
				type: String | Number,
				default () {
					return ''
				}
			}
		},
		methods: {
			makePhoneCall() {
				var that = this;
				if (that.phone) {
					uni.makePhoneCall({
						phoneNumber: that.phone.toString()
					});
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	text {
		font-size: 28rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #4087FF;
		margin-left: 12rpx;
	}
</style>

使用

<call :phone="data.Telephone"></call>

其他相关

uniapp拨打电话
uniapp uview text实现拨打电话

uniapp 拨打电话安卓打包后点击无反应

喜欢 (0)