# uni.installApk(options)

安装apk

本 API 是 uni ext api,需下载插件:uni-installApk

# # Parameters

name type required default description
options InstallApkOptions YES - -

# # InstallApkOptions Values

name type optinal default description
filePath string YES - apk文件地址
success (res: InstallApkSuccess) => void NO null 接口调用成功的回调函数
fail (err: InstallApkFail) => void NO null 接口调用失败的回调函数
complete (res: any) => void NO null 接口调用结束的回调函数(调用成功、失败都会执行)
# # InstallApkSuccess Values
name type optinal default description
errMsg string YES - 安装成功消息
# # InstallApkFail Values
name type optinal default description
errCode number YES - 错误码 - 1300002 找不到文件

# # installApk Compatibility

Android version Android uni-app Android uni-app-x iOS version iOS uni-app iOS uni-app-x
4.4 3.94+ 3.94+ x x x

# # See also

Related Bug

# # Example

hello uni-app x

<template>
 <!-- #ifdef APP -->
 <scroll-view style="flex: 1">
 <!-- #endif -->
   <view>
     <page-head :title="title"></page-head>
     <view class="uni-common-mt">
       <view class="uni-padding-wrap">
         <view class="uni-btn-v">
           <button type="primary" @tap="installApk">
             installApk
           </button>
         </view>
       </view>
     </view>
   </view>
 <!-- #ifdef APP -->
 </scroll-view>
 <!-- #endif -->
</template>
<script>
 export default {
   data() {
     return {
       title: 'installApk'
     }
   },
   onUnload: function () {
   },
   methods: {
     installApk: function () {
       uni.installApk({
         filePath: "/static/test-apk/test.apk",
         complete(res : any) {
           console.log(res);
         }
       })
     },
   }
 }
</script>

<style>
 .uni-pd {
   padding-left: 30rpx;
 }
</style>

# # General type

# # GeneralCallbackResult

name type optinal default description
errMsg string YES - 错误信息