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>