
简体中文
拨打电话
Web | 微信小程序 | Android | iOS | iOS uni-app x UTS 插件 | HarmonyOS | HarmonyOS uni-app x UTS 插件 |
---|---|---|---|---|---|---|
4.0 | 4.41 | 4.63 | 4.63 | 4.63 | 4.61 | 4.61 |
注意
HarmonyOS
平台使用时需要添加受限开放权限 ohos.permission.WRITE_CONTACTS名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | MakePhoneCallOptions | 是 | - | - | |||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
errCode | number | 是 | - | - | |||||||||||||
| |||||||||||||||||
errSubject | string | 是 | - | - | 统一错误主题(模块)名称 | ||||||||||||
data | any | 否 | - | - | 错误信息中包含的数据 | ||||||||||||
cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError | ||||||||||||
errMsg | string | 是 | - | - |
示例为hello uni-app x alpha分支,与最新HBuilderX Alpha版同步。与最新正式版同步的master分支示例另见
示例
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-hello-text uni-center">请在下方输入电话号码</view>
<input class="input uni-common-mt" type="number" name="input" @input="bindInput" />
<view class="uni-btn-v uni-common-mt">
<button @tap="makePhoneCall" type="primary" :disabled="disabled">拨打</button>
</view>
</view>
</view>
</template>
<script lang="uts">
export default {
data() {
return {
title: 'makePhoneCall',
disabled: true,
inputValue: ''
}
},
methods: {
bindInput: function (e : UniInputEvent) {
this.inputValue = e.detail.value
if (this.inputValue.length > 0) {
this.disabled = false
} else {
this.disabled = true
}
},
makePhoneCall: function () {
uni.makePhoneCall({
phoneNumber: this.inputValue,
success: () => {
console.log("成功拨打电话")
},
fail: (err) => {
console.log(err.errCode)
uni.showToast({
title: '错误码:' + err.errCode.toString(),
icon: "error"
})
}
})
}
}
}
</script>
<style>
.input {
height: 60px;
line-height: 60px;
font-size: 39px;
border-bottom: 1px solid #E2E2E2;
text-align: center;
}
</style>
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | 错误信息 |