Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
unidocs-uni-app-x-zh
提交
5d7042c5
U
unidocs-uni-app-x-zh
项目概览
DCloud
/
unidocs-uni-app-x-zh
通知
144
Star
2
Fork
33
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
9
列表
看板
标记
里程碑
合并请求
11
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
unidocs-uni-app-x-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
9
Issue
9
列表
看板
标记
里程碑
合并请求
11
合并请求
11
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
5d7042c5
编写于
5月 10, 2024
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into vue
上级
46f0c45e
c3a3c3b0
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
29 addition
and
12 deletion
+29
-12
docs/.vuepress/markdown/inject-json-to-md.js
docs/.vuepress/markdown/inject-json-to-md.js
+2
-2
docs/.vuepress/utils/customTypeJson.json
docs/.vuepress/utils/customTypeJson.json
+1
-1
docs/.vuepress/utils/utsApiJson.json
docs/.vuepress/utils/utsApiJson.json
+1
-1
docs/.vuepress/utils/utsUnicloudApiJson.json
docs/.vuepress/utils/utsUnicloudApiJson.json
+1
-1
docs/api/ext.md
docs/api/ext.md
+1
-0
docs/api/get-current-pages.md
docs/api/get-current-pages.md
+4
-3
docs/tutorial/request.md
docs/tutorial/request.md
+2
-2
docs/uts/buildin-object-api/global.md
docs/uts/buildin-object-api/global.md
+1
-1
docs/uts/buildin-object-api/timers.md
docs/uts/buildin-object-api/timers.md
+16
-1
未找到文件。
docs/.vuepress/markdown/inject-json-to-md.js
浏览文件 @
5d7042c5
...
@@ -201,8 +201,8 @@ module.exports = md => {
...
@@ -201,8 +201,8 @@ module.exports = md => {
if
(
!
temp
)
return
false
if
(
!
temp
)
return
false
temp
=
temp
[
key
]
temp
=
temp
[
key
]
})
})
if
(
!
temp
)
continue
if
(
typeof
temp
===
'
undefined
'
)
continue
lines
[
index
]
=
lines
[
index
].
replace
(
regExp
,
temp
)
lines
[
index
]
=
temp
}
}
}
}
...
...
docs/.vuepress/utils/customTypeJson.json
浏览文件 @
5d7042c5
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
docs/.vuepress/utils/utsApiJson.json
浏览文件 @
5d7042c5
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
docs/.vuepress/utils/utsUnicloudApiJson.json
浏览文件 @
5d7042c5
{
"uniCloud_props"
:{
"name"
:
"# uniCloud"
,
"description"
:
""
,
"param"
:
"## 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| config | **UniCloudInitOptions** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| provider | string | 是 | - | 服务商,目前支持 aliyun、tencent、alipay |
\n
@| spaceName | string | 否 | - | 服务空间名 |
\n
@| spaceId | string | 是 | - | 服务空间id |
\n
@| clientSecret | string | 否 | - | 阿里云clientSecret |
\n
@| endpoint | string | 否 | - | 阿里云endpoint |
\n
@| spaceAppId | string | 否 | - | 支付宝小程序云spaceAppId |
\n
@| accessKey | string | 否 | - | 支付宝小程序云accessKey |
\n
@| secretKey | string | 否 | - | 支付宝小程序云secretKey |
\n
| mixinDatacom | any | 是 | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"callFunction"
:{
"name"
:
"## callFunction(options) @callfunction"
,
"description"
:
"请求云函数"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | **UniCloudCallFunctionOptions** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| name | string ([string.CloudFunctionString](/uts/data-type.md#ide-string)) | 是 | - | 云函数名 |
\n
@| data | any | 否 | - | 云函数参数 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudCallFunctionResult
\\
<T>](#unicloudcallfunctionresult-values)> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| result | T | 是 | - | 云函数返回结果 |
\n
@| requestId | string | 否 | - | 云函数请求id |
\n
"
,
"compatibility"
:
"### callFunction 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-call-function.callFunction)
\n
"
},
"unicloud-call-function"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud-call-function/unicloud-call-function.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/unicloud-call-function/unicloud-call-function
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
callFunction
\"
>请求云函数</button>
\n
<button type=
\"
primary
\"
@click=
\"
callFunctionWithGeneric
\"
>请求云函数传入泛型</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '请求云函数',
\n
callFunctionResult: {},
\n
callFunctionError: {},
\n
genericDemoShowMessage: '',
\n
isUniTest: false
\n
}
\n
},
\n
onLoad() {
\n
},
\n
onUnload() {
\n
if (this.isUniTest) {
\n
uni.hideToast()
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async callFunctionWithGeneric() : Promise<void> {
\n
type EchoCfResult = {
\n
showMessage: string
\n
}
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
await uniCloud.callFunction<EchoCfResult>({
\n
name: 'echo-cf',
\n
data: {
\n
num: 1,
\n
str: 'ABC'
\n
}
\n
}).then(res => {
\n
const result = res.result
\n
uni.hideLoading()
\n
this.genericDemoShowMessage = result.showMessage
\n
this.notify(result.showMessage, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.callFunctionError = {
\n
errCode: error.errCode,
\n
errMsg: error.errMsg
\n
}
\n
uni.hideLoading()
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async callFunction() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
await uniCloud.callFunction({
\n
name: 'echo-cf',
\n
data: {
\n
num: 1,
\n
str: 'ABC'
\n
}
\n
}).then(res => {
\n
const result = res.result
\n
this.callFunctionResult = result
\n
console.log(JSON.stringify(result))
\n
uni.hideLoading()
\n
this.notify(result['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.callFunctionError = {
\n
errCode: error.errCode,
\n
errMsg: error.errMsg
\n
}
\n
uni.hideLoading()
\n
this.notify(error.errMsg, '错误')
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"importObject"
:{
"name"
:
"## importObject(objectName, options?) @importobject"
,
"description"
:
"引用云对象"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| objectName | string ([string.CloudObjectString](/uts/data-type.md#ide-string)) | 是 | - | - |
\n
| options | **UniCloudImportObjectOptions** | 否 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| customUI | boolean
\\
| null | 否 | - | 是否移除自动展示的ui |
\n
@| loadingOptions | **UniCloudImportObjectLoadingOptions**
\\
| null | 否 | - | loading界面配置 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| title | string
\\
| null | 否 | - | 加载框标题 |
\n
@@| mask | boolean
\\
| null | 否 | - | 加载框是否显示mask |
\n
@| errorOptions | **UniCloudImportObjectErrorOptions**
\\
| null | 否 | - | 错误提示配置 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| type | string
\\
| null | 否 | - | 错误提示类型,可以是modal或者toast |
\n
@@| retry | boolean
\\
| null | 否 | - | 是否显示重试按钮 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudCloudObjectCaller](#unicloudcloudobjectcaller-values) |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| _obj | [InternalUniCloudCloudObject](#internalunicloudcloudobject-values) | 是 | - | - |
\n
##### InternalUniCloudCloudObject 的方法 @internalunicloudcloudobject-values
\n\n
##### callMethod(methodName, args) @callmethod
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| methodName | string | 是 | - | - |
\n
| args | Array
\\
<any
\\
| null
\\
> | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<T> |
\n
\n\n\n\n
#### UniCloudCloudObjectCaller 的方法 @unicloudcloudobjectcaller-values
\n\n
#### _getArgs(args?) @_getargs
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| args | Array
\\
<any
\\
| null
\\
> | 否 | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Array
\\
<any
\\
| null
\\
> |
\n
\n\n\n
\n
"
,
"compatibility"
:
"### importObject 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-import-object.importObject)
\n
"
},
"unicloud-import-object"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud-import-object/unicloud-import-object.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/unicloud-import-object/unicloud-import-object
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
addTodo
\"
>添加Todo</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
addTodoWithGeneric
\"
>添加Todo传入泛型</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
randomFail
\"
>随机触发失败重试</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
fail
\"
>云对象失败调用</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
failWithNumberErrCode
\"
>云对象数字错误码</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
success
\"
>云对象成功调用</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '请求云对象',
\n
todoTitle: '学习编程',
\n
todoContent: '熟悉uts语法',
\n
returnTodoTitle: '',
\n
returnTodoContent: '',
\n
genericDemoReturnTodoTitle: '',
\n
genericDemoReturnTodoContent: '',
\n
failErrCode: '',
\n
failNumberErrCode: 0,
\n
successErrCode: -1,
\n
isUniTest: false
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async addTodo() : Promise<void> {
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
const title = this.todoTitle
\n
const content = this.todoContent
\n
await todo.add<UTSJSONObject>(title, content).then((res : UTSJSONObject) => {
\n
this.returnTodoTitle = res['title'] as string
\n
this.returnTodoContent = res['content'] as string
\n
this.notify(res['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
console.log(err)
\n
const error = err as UniCloudError
\n
console.error(error)
\n
})
\n
},
\n
async addTodoWithGeneric() : Promise<void> {
\n
type AddTodoResult = {
\n
title: string,
\n
content: string,
\n
showMessage: string
\n
}
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
const title = this.todoTitle
\n
const content = this.todoContent
\n
await todo.add<AddTodoResult>(title, content).then((res : AddTodoResult) => {
\n
this.genericDemoReturnTodoTitle = res.title
\n
this.genericDemoReturnTodoContent = res.content
\n
this.notify(res.showMessage, '提示')
\n
}).catch((err : any | null) => {
\n
console.log(err)
\n
const error = err as UniCloudError
\n
console.error(error)
\n
})
\n
},
\n
async randomFail() : Promise<void> {
\n
const todoObj = uniCloud.importObject('todo', {
\n
errorOptions: {
\n
retry: true
\n
}
\n
})
\n
await todoObj.randomFail().then((res : UTSJSONObject) => {
\n
this.notify(res['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
console.error(error)
\n
})
\n
},
\n
async fail() : Promise<void> {
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
await todo.fail().then((res : UTSJSONObject) => {
\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\n
console.log('todo.fail: ', res);
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.failErrCode = error.errCode as string
\n
console.error(error)
\n
})
\n
},
\n
async failWithNumberErrCode() : Promise<void> {
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
await todo.failWithNumberErrCode().then((res : UTSJSONObject) => {
\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\n
console.log('todo.fail: ', res);
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.failNumberErrCode = error.errCode as number
\n
console.error(error)
\n
})
\n
},
\n
async success() : Promise<void> {
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
await todo.success().then((res : UTSJSONObject) => {
\n
this.successErrCode = res['errCode'] as number
\n
this.notify(res['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
console.error(error)
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"uploadFile"
:{
"name"
:
"## uploadFile(options) @uploadfile"
,
"description"
:
"上传文件到云存储"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudUploadFileOptions](#uniclouduploadfileoptions-values) | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| filePath | string | 是 | - | 文件路径 |
\n
@| cloudPath | string | 是 | - | 云端路径 |
\n
@| cloudPathAsRealPath | boolean | 否 | - | 是否以云端路径是否为真实路径保存上传的文件 |
\n\n
#### UniCloudUploadFileOptions 的方法 @uniclouduploadfileoptions-values
\n\n
#### onUploadProgress(options) @onuploadprogress
\n\n
上传进度回调
\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | **UniCloudUploadProgress** | 是 | - | 上传进度回调参数 |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| loaded | number | 是 | - | 已上传大小 |
\n
@| total | number | 是 | - | 总大小 |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudUploadFileResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| filePath | string | 是 | - | 文件路径 |
\n
@| fileID | string | 是 | - | 文件id |
\n
"
,
"compatibility"
:
"### uploadFile 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-file-api.upload-file)
\n
"
},
"getTempFileURL"
:{
"name"
:
"## getTempFileURL(options) @gettempfileurl"
,
"description"
:
"获取文件临时URL"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | **UniCloudGetTempFileURLOptions** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| fileList | Array
\\
<string
\\
> | 是 | - | 文件列表 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudGetTempFileURLResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| fileList | Array
\\
<**UniCloudGetTempFileURLResultItem**
\\
> | 是 | - | 文件列表 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| fileID | string | 是 | - | 文件id |
\n
@@| tempFileURL | string | 是 | - | 文件临时url |
\n
"
,
"compatibility"
:
"### getTempFileURL 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-file-api.choose-and-upload-file)
\n
"
},
"chooseAndUploadFile"
:{
"name"
:
"## chooseAndUploadFile(options) @chooseanduploadfile"
,
"description"
:
"选择并上传文件"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudChooseAndUploadFileOptions](#unicloudchooseanduploadfileoptions-values) | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| sourceType | Array
\\
<string
\\
>
\\
| null | 否 | - | |
\n
@| count | number
\\
| null | 否 | - | |
\n
@| sizeType | Array
\\
<string
\\
>
\\
| null | 否 | - | |
\n
@| extension | Array
\\
<string
\\
>
\\
| null | 否 | - | |
\n
@| compressed | boolean
\\
| null | 否 | - | |
\n
@| maxDuration | number
\\
| null | 否 | - | |
\n
@| camera | string
\\
| null | 否 | - | |
\n
@| crop | ChooseImageCropOptions
\\
| null | 否 | - | |
\n
@| type | string | 是 | - | - |
\n\n
#### UniCloudChooseAndUploadFileOptions 的方法 @unicloudchooseanduploadfileoptions-values
\n\n
#### onChooseFile(arg) @onchoosefile
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | **UniCloudChooseFileResult** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| tempFiles | Array
\\
<**UniCloudChooseFileItem**
\\
> | 是 | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| name | string | 是 | - | - |
\n
@@| path | string | 是 | - | - |
\n
@@| cloudPath | string | 是 | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | |
\n
@@| url | string
\\
| null | 否 | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | |
\n
@| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - |
\n\n
##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| void
\\
| null | 否 |
\n
\n\n\n\n
#### onUploadProgress(arg) @onuploadprogress
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | **UniCloudChooseAndUploadFileProgressEvent** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| index | number | 是 | - | - |
\n
@| loaded | number | 是 | - | - |
\n
@| total | number | 是 | - | - |
\n
@| tempFilePath | string | 是 | - | - |
\n
@| tempFile | [UniCloudChooseFileItem](#unicloudchoosefileitem-values) | 是 | - | - |
\n\n
##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| void
\\
| null | 否 |
\n
\n\n\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudChooseAndUploadFileResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| tempFiles | Array
\\
<**UniCloudChooseFileItem**
\\
> | 是 | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| name | string | 是 | - | - |
\n
@@| path | string | 是 | - | - |
\n
@@| cloudPath | string | 是 | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | |
\n
@@| url | string
\\
| null | 否 | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | |
\n
@| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - |
\n
"
,
"compatibility"
:
"### chooseAndUploadFile 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-file-api.getTempFileURL)
\n
"
},
"unicloud-file-api"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud-file-api/unicloud-file-api.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/unicloud-file-api/unicloud-file-api
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
uploadFile
\"
>选择文件上传</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '云存储'
\n
}
\n
},
\n
onLoad() {
\n
},
\n
onUnload() {
\n
},
\n
methods: {
\n
uploadFile: function () {
\n
uni.chooseImage({
\n
count: 1,
\n
success(res) : void {
\n
uni.showLoading({
\n
title: '上传中...'
\n
})
\n
const tempFilePath = res.tempFilePaths[0]
\n
uniCloud.uploadFile({
\n
filePath: tempFilePath,
\n
cloudPath: 'test.jpg'
\n
})
\n
.then(function (res) {
\n
uni.hideLoading()
\n
console.log(res)
\n
uni.showModal({
\n
content: '上传成功',
\n
showCancel: false
\n
});
\n
})
\n
.catch(function (err : any | null) {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
uni.showModal({
\n
content: '上传失败,' + error.errMsg,
\n
showCancel: false
\n
});
\n
})
\n
// .finally((_: number) : void => {
\n
// uni.hideLoading()
\n
// })
\n
},
\n
fail(err) : void {
\n
console.error('chooseImage fail: ', err)
\n
}
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"databaseForJQL"
:{
"name"
:
"## databaseForJQL() @databaseforjql"
,
"description"
:
"获取数据库操作实例"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Database](#database-values) |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| command | any | 是 | - | - |
\n
@| Geo | any | 是 | - | - |
\n
#### Database 的方法 @database-values
\n\n
#### collection(args?) @collection
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Collection](#collection-values) |
\n\n
##### Collection 的方法 @collection-values
\n\n
##### where(condition) @where
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| condition | any | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n
##### UniCloudDBFilter 的方法 @uniclouddbfilter-values
\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any
\\
| null | 否 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBGetResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| data | Array
\\
<any
\\
> | 是 | - | etResult = { /** |
\n
@| count | number
\\
| null | 否 | - | JSONObject>;<br/> /** |
\n
@| requestId | string | 否 | - | ber
\\
| null; / |
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBCountResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| total | number | 是 | - | ntResult = { /** |
\n
@| requestId | string | 否 | - | al: number; / |
\n\n\n\n
##### update(data) @update
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| data | any | 是 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBUpdateResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| updated | number | 是 | - | teResult = { /** |
\n
@| requestId | string | 否 | - | ted: number; / |
\n\n\n\n
##### remove() @remove
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBRemoveResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| deleted | number | 是 | - | veResult = { /** |
\n
@| requestId | string | 否 | - | ted: number; / |
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n\n\n
##### where(condition) @where
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| condition | any | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### doc(docId) @doc
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| docId | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n
##### UniCloudDBQuery 的方法 @uniclouddbquery-values
\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any
\\
| null | 否 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### groupBy(field) @groupby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### groupField(field) @groupfield
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### distinct(field) @distinct
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### geoNear(options) @geonear
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | any | 是 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### groupBy(field) @groupby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### groupField(field) @groupfield
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### distinct(field) @distinct
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### geoNear(options) @geonear
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | any | 是 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n
\n\n\n\n
##### doc(docId) @doc
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| docId | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### aggregate() @aggregate
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### foreignKey(foreignKey) @foreignkey
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| foreignKey | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### add(data) @add
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| data | any | 是 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBAddResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| id | string | 是 | - | ddResult = { /** |
\n
@| requestId | string | 否 | - | string; / |
\n\n\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any
\\
| null | 否 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n
\n\n\n
\n
"
,
"compatibility"
:
"### databaseForJQL 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.91,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-database.databaseForJQL)
\n
"
},
"unicloud-database"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud-database/unicloud-database.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/unicloud-database/unicloud-database
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
dbAdd
\"
>新增单条数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbBatchAdd
\"
>新增多条数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbUpdate
\"
>更新数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbGet
\"
>where传字符串获取数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbGetWithCommand
\"
>where传对象获取数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbRemove
\"
>删除数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbLookupInit
\"
>初始化联表查询数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbLookup
\"
>联表查询</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: 'ClientDB',
\n
addId: '',
\n
batchAddIds: [] as Array<string>,
\n
batchAddinserted: 0,
\n
updateUpdated: 0,
\n
getData: [] as Array<UTSJSONObject>,
\n
getWithCommandData: [] as Array<UTSJSONObject>,
\n
removeDeleted: 0,
\n
lookupData: [] as Array<UTSJSONObject>,
\n
isUniTest: false
\n
}
\n
},
\n
computed: {
\n
dataTag() : string {
\n
return this.isUniTest ? 'default-tag' + Date.now() : 'default-tag'
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async dbAdd() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.add({
\n
num: 1,
\n
tag: this.dataTag,
\n
date: new Date()
\n
})
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.addId = res.id
\n
this.notify(`新增成功,id: ${res.id}`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbBatchAdd() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.add([{
\n
num: 2,
\n
tag: this.dataTag,
\n
}, {
\n
num: 3,
\n
tag: this.dataTag,
\n
}])
\n
.then((res) => {
\n
uni.hideLoading()
\n
console.log(res)
\n
console.log('JSON.stringify(res.inserted)', JSON.stringify(res.inserted))
\n
this.batchAddIds = res.ids
\n
this.batchAddinserted = res.inserted
\n
this.notify(`新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbGet() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.field('num, tag')
\n
.orderBy('num desc')
\n
.skip(1)
\n
.limit(2)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.getData = res.data
\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbGetWithCommand() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where({
\n
num: db.command.gt(1),
\n
tag: this.dataTag
\n
})
\n
.field('num, tag')
\n
.orderBy('num desc')
\n
.skip(1)
\n
.limit(2)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.getWithCommandData = res.data
\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbUpdate() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.update({
\n
num: 4
\n
})
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.updateUpdated = res.updated
\n
this.notify(`更新成功,更新了${res.updated}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbRemove() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.remove()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.removeDeleted = res.deleted
\n
this.notify(`删除成功,删掉了${res.deleted}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbLookupInit() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('local')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.remove()
\n
.then(() : Promise<UniCloudDBRemoveResult> => {
\n
return db.collection('foreign')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.remove()
\n
})
\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\n
return db.collection('local')
\n
.add([{
\n
id:
\"
local_1
\"
,
\n
name:
\"
local_1_name
\"
,
\n
tag: this.dataTag,
\n
foreign_id:
\"
foreign_1
\"\n
}, {
\n
id:
\"
local_2
\"
,
\n
name:
\"
local_2_name
\"
,
\n
tag: this.dataTag,
\n
foreign_id:
\"
foreign_2
\"\n
}])
\n
})
\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\n
return db.collection('foreign')
\n
.add([{
\n
id:
\"
foreign_1
\"
,
\n
name:
\"
foreign_1_name
\"
,
\n
tag: this.dataTag
\n
}, {
\n
id:
\"
foreign_2
\"
,
\n
name:
\"
foreign_2_name
\"
,
\n
tag: this.dataTag
\n
}])
\n
})
\n
.then((_) : void => {
\n
uni.hideLoading()
\n
this.notify('数据初始化成功', '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
console.error(err)
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbLookup() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
const local = db.collection('local')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.getTemp()
\n
const foreign = db.collection('foreign')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.getTemp()
\n
await db.collection(local, foreign)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.lookupData = res.data
\n
this.notify(`联表查询成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"onResponse"
:{
"name"
:
"## onResponse(callback) @onresponse"
,
"description"
:
"监听响应事件"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### onResponse 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.get-current-user-info)
\n
"
},
"offResponse"
:{
"name"
:
"## offResponse(callback) @offresponse"
,
"description"
:
"移除响应事件监听"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### offResponse 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.on-response)
\n
"
},
"onRefreshToken"
:{
"name"
:
"## onRefreshToken(callback) @onrefreshtoken"
,
"description"
:
"监听token刷新事件"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### onRefreshToken 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.off-response)
\n
"
},
"offRefreshToken"
:{
"name"
:
"## offRefreshToken(callback) @offrefreshtoken"
,
"description"
:
"移除token刷新事件监听"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### offRefreshToken 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.on-refresh-token)
\n
"
},
"getCurrentUserInfo"
:{
"name"
:
"## getCurrentUserInfo() @getcurrentuserinfo"
,
"description"
:
"获取token内缓存的用户信息"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| **UniCloudUserInfo** |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| uid | string
\\
| null | 否 | - | UserInfo = {<br/> / |
\n
@| role | Array
\\
<string
\\
> | 是 | - | ing
\\
| null; / |
\n
@| permission | Array
\\
<string
\\
> | 是 | - | ay
\\
<string>; / |
\n
@| tokenExpired | number | 是 | - | ay
\\
<string>; /** |
\n
"
,
"compatibility"
:
"### getCurrentUserInfo 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.off-refresh-token)
\n
"
}}
{
"uniCloud_props"
:{
"name"
:
"# uniCloud"
,
"description"
:
""
,
"param"
:
"## 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| config | **UniCloudInitOptions** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| provider | string | 是 | - | 服务商,目前支持 aliyun、tencent、alipay |
\n
@| spaceName | string | 否 | - | 服务空间名 |
\n
@| spaceId | string | 是 | - | 服务空间id |
\n
@| clientSecret | string | 否 | - | 阿里云clientSecret |
\n
@| endpoint | string | 否 | - | 阿里云endpoint |
\n
@| spaceAppId | string | 否 | - | 支付宝小程序云spaceAppId |
\n
@| accessKey | string | 否 | - | 支付宝小程序云accessKey |
\n
@| secretKey | string | 否 | - | 支付宝小程序云secretKey |
\n
| mixinDatacom | any | 是 | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"callFunction"
:{
"name"
:
"## callFunction(options) @callfunction"
,
"description"
:
"请求云函数"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | **UniCloudCallFunctionOptions** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| name | string ([string.CloudFunctionString](/uts/data-type.md#ide-string)) | 是 | - | 云函数名 |
\n
@| data | any | 否 | - | 云函数参数 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudCallFunctionResult
\\
<T>](#unicloudcallfunctionresult-values)> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| result | T | 是 | - | 云函数返回结果 |
\n
@| requestId | string | 否 | - | 云函数请求id |
\n
"
,
"compatibility"
:
"### callFunction 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-call-function.callFunction)
\n
"
},
"unicloud-call-function"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud-call-function/unicloud-call-function.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/unicloud-call-function/unicloud-call-function
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
callFunction
\"
>请求云函数</button>
\n
<button type=
\"
primary
\"
@click=
\"
callFunctionWithGeneric
\"
>请求云函数传入泛型</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '请求云函数',
\n
callFunctionResult: {},
\n
callFunctionError: {},
\n
genericDemoShowMessage: '',
\n
isUniTest: false
\n
}
\n
},
\n
onLoad() {
\n
},
\n
onUnload() {
\n
if (this.isUniTest) {
\n
uni.hideToast()
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async callFunctionWithGeneric() : Promise<void> {
\n
type EchoCfResult = {
\n
showMessage: string
\n
}
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
await uniCloud.callFunction<EchoCfResult>({
\n
name: 'echo-cf',
\n
data: {
\n
num: 1,
\n
str: 'ABC'
\n
}
\n
}).then(res => {
\n
const result = res.result
\n
uni.hideLoading()
\n
this.genericDemoShowMessage = result.showMessage
\n
this.notify(result.showMessage, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.callFunctionError = {
\n
errCode: error.errCode,
\n
errMsg: error.errMsg
\n
}
\n
uni.hideLoading()
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async callFunction() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
await uniCloud.callFunction({
\n
name: 'echo-cf',
\n
data: {
\n
num: 1,
\n
str: 'ABC'
\n
}
\n
}).then(res => {
\n
const result = res.result
\n
this.callFunctionResult = result
\n
console.log(JSON.stringify(result))
\n
uni.hideLoading()
\n
this.notify(result['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.callFunctionError = {
\n
errCode: error.errCode,
\n
errMsg: error.errMsg
\n
}
\n
uni.hideLoading()
\n
this.notify(error.errMsg, '错误')
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"importObject"
:{
"name"
:
"## importObject(objectName, options?) @importobject"
,
"description"
:
"引用云对象"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| objectName | string ([string.CloudObjectString](/uts/data-type.md#ide-string)) | 是 | - | - |
\n
| options | **UniCloudImportObjectOptions** | 否 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| customUI | boolean
\\
| null | 否 | - | 是否移除自动展示的ui |
\n
@| loadingOptions | **UniCloudImportObjectLoadingOptions**
\\
| null | 否 | - | loading界面配置 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| title | string
\\
| null | 否 | - | 加载框标题 |
\n
@@| mask | boolean
\\
| null | 否 | - | 加载框是否显示mask |
\n
@| errorOptions | **UniCloudImportObjectErrorOptions**
\\
| null | 否 | - | 错误提示配置 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| type | string
\\
| null | 否 | - | 错误提示类型,可以是modal或者toast |
\n
@@| retry | boolean
\\
| null | 否 | - | 是否显示重试按钮 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudCloudObjectCaller](#unicloudcloudobjectcaller-values) |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| _obj | [InternalUniCloudCloudObject](#internalunicloudcloudobject-values) | 是 | - | - |
\n
##### InternalUniCloudCloudObject 的方法 @internalunicloudcloudobject-values
\n\n
##### callMethod(methodName, args) @callmethod
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| methodName | string | 是 | - | - |
\n
| args | Array
\\
<any
\\
| null
\\
> | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<T> |
\n
\n\n\n\n
#### UniCloudCloudObjectCaller 的方法 @unicloudcloudobjectcaller-values
\n\n
#### _getArgs(args?) @_getargs
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| args | Array
\\
<any
\\
| null
\\
> | 否 | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Array
\\
<any
\\
| null
\\
> |
\n
\n\n\n
\n
"
,
"compatibility"
:
"### importObject 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-import-object.importObject)
\n
"
},
"unicloud-import-object"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud-import-object/unicloud-import-object.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/unicloud-import-object/unicloud-import-object
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
addTodo
\"
>添加Todo</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
addTodoWithGeneric
\"
>添加Todo传入泛型</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
randomFail
\"
>随机触发失败重试</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
fail
\"
>云对象失败调用</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
failWithNumberErrCode
\"
>云对象数字错误码</button>
\n
</view>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@tap=
\"
success
\"
>云对象成功调用</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '请求云对象',
\n
todoTitle: '学习编程',
\n
todoContent: '熟悉uts语法',
\n
returnTodoTitle: '',
\n
returnTodoContent: '',
\n
genericDemoReturnTodoTitle: '',
\n
genericDemoReturnTodoContent: '',
\n
failErrCode: '',
\n
failNumberErrCode: 0,
\n
successErrCode: -1,
\n
isUniTest: false
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async addTodo() : Promise<void> {
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
const title = this.todoTitle
\n
const content = this.todoContent
\n
await todo.add<UTSJSONObject>(title, content).then((res : UTSJSONObject) => {
\n
this.returnTodoTitle = res['title'] as string
\n
this.returnTodoContent = res['content'] as string
\n
this.notify(res['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
console.log(err)
\n
const error = err as UniCloudError
\n
console.error(error)
\n
})
\n
},
\n
async addTodoWithGeneric() : Promise<void> {
\n
type AddTodoResult = {
\n
title: string,
\n
content: string,
\n
showMessage: string
\n
}
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
const title = this.todoTitle
\n
const content = this.todoContent
\n
await todo.add<AddTodoResult>(title, content).then((res : AddTodoResult) => {
\n
this.genericDemoReturnTodoTitle = res.title
\n
this.genericDemoReturnTodoContent = res.content
\n
this.notify(res.showMessage, '提示')
\n
}).catch((err : any | null) => {
\n
console.log(err)
\n
const error = err as UniCloudError
\n
console.error(error)
\n
})
\n
},
\n
async randomFail() : Promise<void> {
\n
const todoObj = uniCloud.importObject('todo', {
\n
errorOptions: {
\n
retry: true
\n
}
\n
})
\n
await todoObj.randomFail().then((res : UTSJSONObject) => {
\n
this.notify(res['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
console.error(error)
\n
})
\n
},
\n
async fail() : Promise<void> {
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
await todo.fail().then((res : UTSJSONObject) => {
\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\n
console.log('todo.fail: ', res);
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.failErrCode = error.errCode as string
\n
console.error(error)
\n
})
\n
},
\n
async failWithNumberErrCode() : Promise<void> {
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
await todo.failWithNumberErrCode().then((res : UTSJSONObject) => {
\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\n
console.log('todo.fail: ', res);
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.failNumberErrCode = error.errCode as number
\n
console.error(error)
\n
})
\n
},
\n
async success() : Promise<void> {
\n
const todo = uniCloud.importObject('todo', {
\n
customUI: this.isUniTest
\n
})
\n
await todo.success().then((res : UTSJSONObject) => {
\n
this.successErrCode = res['errCode'] as number
\n
this.notify(res['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
console.error(error)
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"uploadFile"
:{
"name"
:
"## uploadFile(options) @uploadfile"
,
"description"
:
"上传文件到云存储"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudUploadFileOptions](#uniclouduploadfileoptions-values) | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| filePath | string | 是 | - | 文件路径 |
\n
@| cloudPath | string | 是 | - | 云端路径 |
\n
@| cloudPathAsRealPath | boolean | 否 | - | 是否以云端路径是否为真实路径保存上传的文件 |
\n\n
#### UniCloudUploadFileOptions 的方法 @uniclouduploadfileoptions-values
\n\n
#### onUploadProgress(options) @onuploadprogress
\n\n
上传进度回调
\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | **UniCloudUploadProgress** | 是 | - | 上传进度回调参数 |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| loaded | number | 是 | - | 已上传大小 |
\n
@| total | number | 是 | - | 总大小 |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudUploadFileResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| filePath | string | 是 | - | 文件路径 |
\n
@| fileID | string | 是 | - | 文件id |
\n
"
,
"compatibility"
:
"### uploadFile 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-file-api.upload-file)
\n
"
},
"getTempFileURL"
:{
"name"
:
"## getTempFileURL(options) @gettempfileurl"
,
"description"
:
"获取文件临时URL"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | **UniCloudGetTempFileURLOptions** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| fileList | Array
\\
<string
\\
> | 是 | - | 文件列表 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudGetTempFileURLResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| fileList | Array
\\
<**UniCloudGetTempFileURLResultItem**
\\
> | 是 | - | 文件列表 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| fileID | string | 是 | - | 文件id |
\n
@@| tempFileURL | string | 是 | - | 文件临时url |
\n
"
,
"compatibility"
:
"### getTempFileURL 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-file-api.choose-and-upload-file)
\n
"
},
"chooseAndUploadFile"
:{
"name"
:
"## chooseAndUploadFile(options) @chooseanduploadfile"
,
"description"
:
"选择并上传文件"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudChooseAndUploadFileOptions](#unicloudchooseanduploadfileoptions-values) | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| sourceType | Array
\\
<string
\\
>
\\
| null | 否 | - | |
\n
@| count | number
\\
| null | 否 | - | |
\n
@| sizeType | Array
\\
<string
\\
>
\\
| null | 否 | - | |
\n
@| extension | Array
\\
<string
\\
>
\\
| null | 否 | - | |
\n
@| compressed | boolean
\\
| null | 否 | - | |
\n
@| maxDuration | number
\\
| null | 否 | - | |
\n
@| camera | string
\\
| null | 否 | - | |
\n
@| crop | ChooseImageCropOptions
\\
| null | 否 | - | |
\n
@| type | string | 是 | - | - |
\n\n
#### UniCloudChooseAndUploadFileOptions 的方法 @unicloudchooseanduploadfileoptions-values
\n\n
#### onChooseFile(arg) @onchoosefile
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | **UniCloudChooseFileResult** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| tempFiles | Array
\\
<**UniCloudChooseFileItem**
\\
> | 是 | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| name | string | 是 | - | - |
\n
@@| path | string | 是 | - | - |
\n
@@| cloudPath | string | 是 | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | |
\n
@@| url | string
\\
| null | 否 | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | |
\n
@| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - |
\n\n
##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| void
\\
| null | 否 |
\n
\n\n\n\n
#### onUploadProgress(arg) @onuploadprogress
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | **UniCloudChooseAndUploadFileProgressEvent** | 是 | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| index | number | 是 | - | - |
\n
@| loaded | number | 是 | - | - |
\n
@| total | number | 是 | - | - |
\n
@| tempFilePath | string | 是 | - | - |
\n
@| tempFile | [UniCloudChooseFileItem](#unicloudchoosefileitem-values) | 是 | - | - |
\n\n
##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| void
\\
| null | 否 |
\n
\n\n\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudChooseAndUploadFileResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| tempFiles | Array
\\
<**UniCloudChooseFileItem**
\\
> | 是 | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| name | string | 是 | - | - |
\n
@@| path | string | 是 | - | - |
\n
@@| cloudPath | string | 是 | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | |
\n
@@| url | string
\\
| null | 否 | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | |
\n
@| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - |
\n
"
,
"compatibility"
:
"### chooseAndUploadFile 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-file-api.getTempFileURL)
\n
"
},
"unicloud-file-api"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud-file-api/unicloud-file-api.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/unicloud-file-api/unicloud-file-api
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
uploadFile
\"
>选择文件上传</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '云存储'
\n
}
\n
},
\n
onLoad() {
\n
},
\n
onUnload() {
\n
},
\n
methods: {
\n
uploadFile: function () {
\n
uni.chooseImage({
\n
count: 1,
\n
success(res) : void {
\n
uni.showLoading({
\n
title: '上传中...'
\n
})
\n
const tempFilePath = res.tempFilePaths[0]
\n
uniCloud.uploadFile({
\n
filePath: tempFilePath,
\n
cloudPath: 'test.jpg'
\n
})
\n
.then(function (res) {
\n
uni.hideLoading()
\n
console.log(res)
\n
uni.showModal({
\n
content: '上传成功',
\n
showCancel: false
\n
});
\n
})
\n
.catch(function (err : any | null) {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
uni.showModal({
\n
content: '上传失败,' + error.errMsg,
\n
showCancel: false
\n
});
\n
})
\n
// .finally((_: number) : void => {
\n
// uni.hideLoading()
\n
// })
\n
},
\n
fail(err) : void {
\n
console.error('chooseImage fail: ', err)
\n
}
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"databaseForJQL"
:{
"name"
:
"## databaseForJQL() @databaseforjql"
,
"description"
:
"获取数据库操作实例"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Database](#database-values) |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| command | any | 是 | - | - |
\n
@| Geo | any | 是 | - | - |
\n
#### Database 的方法 @database-values
\n\n
#### collection(args?) @collection
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Collection](#collection-values) |
\n\n
##### Collection 的方法 @collection-values
\n\n
##### where(condition) @where
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| condition | any | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n
##### UniCloudDBFilter 的方法 @uniclouddbfilter-values
\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any
\\
| null | 否 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBGetResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| data | Array
\\
<any
\\
> | 是 | - | etResult = { /** |
\n
@| count | number
\\
| null | 否 | - | JSONObject>;<br/> /** |
\n
@| requestId | string | 否 | - | ber
\\
| null; / |
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBCountResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| total | number | 是 | - | ntResult = { /** |
\n
@| requestId | string | 否 | - | al: number; / |
\n\n\n\n
##### update(data) @update
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| data | any | 是 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBUpdateResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| updated | number | 是 | - | teResult = { /** |
\n
@| requestId | string | 否 | - | ted: number; / |
\n\n\n\n
##### remove() @remove
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBRemoveResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| deleted | number | 是 | - | veResult = { /** |
\n
@| requestId | string | 否 | - | ted: number; / |
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n\n\n
##### where(condition) @where
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| condition | any | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### doc(docId) @doc
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| docId | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n
##### UniCloudDBQuery 的方法 @uniclouddbquery-values
\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any
\\
| null | 否 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### groupBy(field) @groupby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### groupField(field) @groupfield
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### distinct(field) @distinct
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### geoNear(options) @geonear
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | any | 是 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### groupBy(field) @groupby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### groupField(field) @groupfield
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### distinct(field) @distinct
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### geoNear(options) @geonear
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | any | 是 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n
\n\n\n\n
##### doc(docId) @doc
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| docId | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### aggregate() @aggregate
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### foreignKey(foreignKey) @foreignkey
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| foreignKey | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n\n\n
##### add(data) @add
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| data | any | 是 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBAddResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| id | string | 是 | - | ddResult = { /** |
\n
@| requestId | string | 否 | - | string; / |
\n\n\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any
\\
| null | 否 | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n\n
\n\n\n\n
#### multiSend(args?) @multisend
\n
合并查询请求
\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBMultiSendResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| dataList | Array
\\
<**UniCloudDBMultiSendResultItem**
\\
> | 是 | - | SendResult = { |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@@| :- | :- | :- | :- | :- |
\n
@@| errCode | any | 是 | - | ResultItem = { /** 错误码,可 |
\n
@@| errMsg | string | 是 | - | errCode : any |
\n
@@| data | Array
\\
<any
\\
> | 否 | - | Msg : stri |
\n
@| requestId | string | 否 | - | ndResultItem[
\\
] |
\n\n
##### multiSend 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 4.16 | 4.11 | 4.0 |
\n\n
\n
"
,
"compatibility"
:
"### databaseForJQL 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.91,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-database.databaseForJQL)
\n
"
},
"unicloud-database"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud-database/unicloud-database.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/unicloud-database/unicloud-database
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
dbAdd
\"
>新增单条数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbBatchAdd
\"
>新增多条数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbUpdate
\"
>更新数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbGet
\"
>where传字符串获取数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbGetWithCommand
\"
>where传对象获取数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbRemove
\"
>删除数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbLookupInit
\"
>初始化联表查询数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbLookup
\"
>联表查询</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: 'ClientDB',
\n
addId: '',
\n
batchAddIds: [] as Array<string>,
\n
batchAddinserted: 0,
\n
updateUpdated: 0,
\n
getData: [] as Array<UTSJSONObject>,
\n
getWithCommandData: [] as Array<UTSJSONObject>,
\n
removeDeleted: 0,
\n
lookupData: [] as Array<UTSJSONObject>,
\n
isUniTest: false
\n
}
\n
},
\n
computed: {
\n
dataTag() : string {
\n
return this.isUniTest ? 'default-tag' + Date.now() : 'default-tag'
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async dbAdd() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.add({
\n
num: 1,
\n
tag: this.dataTag,
\n
date: new Date()
\n
})
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.addId = res.id
\n
this.notify(`新增成功,id: ${res.id}`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbBatchAdd() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.add([{
\n
num: 2,
\n
tag: this.dataTag,
\n
}, {
\n
num: 3,
\n
tag: this.dataTag,
\n
}])
\n
.then((res) => {
\n
uni.hideLoading()
\n
console.log(res)
\n
console.log('JSON.stringify(res.inserted)', JSON.stringify(res.inserted))
\n
this.batchAddIds = res.ids
\n
this.batchAddinserted = res.inserted
\n
this.notify(`新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbGet() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.field('num, tag')
\n
.orderBy('num desc')
\n
.skip(1)
\n
.limit(2)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.getData = res.data
\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbGetWithCommand() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where({
\n
num: db.command.gt(1),
\n
tag: this.dataTag
\n
})
\n
.field('num, tag')
\n
.orderBy('num desc')
\n
.skip(1)
\n
.limit(2)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.getWithCommandData = res.data
\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbUpdate() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.update({
\n
num: 4
\n
})
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.updateUpdated = res.updated
\n
this.notify(`更新成功,更新了${res.updated}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbRemove() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.remove()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.removeDeleted = res.deleted
\n
this.notify(`删除成功,删掉了${res.deleted}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbLookupInit() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('local')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.remove()
\n
.then(() : Promise<UniCloudDBRemoveResult> => {
\n
return db.collection('foreign')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.remove()
\n
})
\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\n
return db.collection('local')
\n
.add([{
\n
id:
\"
local_1
\"
,
\n
name:
\"
local_1_name
\"
,
\n
tag: this.dataTag,
\n
foreign_id:
\"
foreign_1
\"\n
}, {
\n
id:
\"
local_2
\"
,
\n
name:
\"
local_2_name
\"
,
\n
tag: this.dataTag,
\n
foreign_id:
\"
foreign_2
\"\n
}])
\n
})
\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\n
return db.collection('foreign')
\n
.add([{
\n
id:
\"
foreign_1
\"
,
\n
name:
\"
foreign_1_name
\"
,
\n
tag: this.dataTag
\n
}, {
\n
id:
\"
foreign_2
\"
,
\n
name:
\"
foreign_2_name
\"
,
\n
tag: this.dataTag
\n
}])
\n
})
\n
.then((_) : void => {
\n
uni.hideLoading()
\n
this.notify('数据初始化成功', '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
console.error(err)
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbLookup() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
const local = db.collection('local')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.getTemp()
\n
const foreign = db.collection('foreign')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.getTemp()
\n
await db.collection(local, foreign)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.lookupData = res.data
\n
this.notify(`联表查询成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"onResponse"
:{
"name"
:
"## onResponse(callback) @onresponse"
,
"description"
:
"监听响应事件"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### onResponse 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.get-current-user-info)
\n
"
},
"offResponse"
:{
"name"
:
"## offResponse(callback) @offresponse"
,
"description"
:
"移除响应事件监听"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### offResponse 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.on-response)
\n
"
},
"onRefreshToken"
:{
"name"
:
"## onRefreshToken(callback) @onrefreshtoken"
,
"description"
:
"监听token刷新事件"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### onRefreshToken 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.off-response)
\n
"
},
"offRefreshToken"
:{
"name"
:
"## offRefreshToken(callback) @offrefreshtoken"
,
"description"
:
"移除token刷新事件监听"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### offRefreshToken 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.on-refresh-token)
\n
"
},
"getCurrentUserInfo"
:{
"name"
:
"## getCurrentUserInfo() @getcurrentuserinfo"
,
"description"
:
"获取token内缓存的用户信息"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| **UniCloudUserInfo** |
\n
@| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
@| :- | :- | :- | :- | :- |
\n
@| uid | string
\\
| null | 否 | - | UserInfo = {<br/> / |
\n
@| role | Array
\\
<string
\\
> | 是 | - | ing
\\
| null; / |
\n
@| permission | Array
\\
<string
\\
> | 是 | - | ay
\\
<string>; / |
\n
@| tokenExpired | number | 是 | - | ay
\\
<string>; /** |
\n
"
,
"compatibility"
:
"### getCurrentUserInfo 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 | 4.0 |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.unicloud-utils.off-refresh-token)
\n
"
}}
\ No newline at end of file
\ No newline at end of file
docs/api/ext.md
浏览文件 @
5d7042c5
...
@@ -23,6 +23,7 @@ uni-app x的web版从uni-app的js引擎版迁移而来,理论上所有uni-app
...
@@ -23,6 +23,7 @@ uni-app x的web版从uni-app的js引擎版迁移而来,理论上所有uni-app
-
陀螺仪:
`uni.onGyroscopeChange`
、
`uni.startGyroscope`
、
`uni.stopGyroscope`
[
见插件市场
](
https://ext.dcloud.net.cn/plugin?id=17540
)
-
陀螺仪:
`uni.onGyroscopeChange`
、
`uni.startGyroscope`
、
`uni.stopGyroscope`
[
见插件市场
](
https://ext.dcloud.net.cn/plugin?id=17540
)
-
加速度传感器:
`uni.onAccelerometerChange`
、
`uni.startAccelerometer`
[
见插件市场
](
https://ext.dcloud.net.cn/plugin?id=17540
)
-
加速度传感器:
`uni.onAccelerometerChange`
、
`uni.startAccelerometer`
[
见插件市场
](
https://ext.dcloud.net.cn/plugin?id=17540
)
-
生物识别:指纹识别。
`uni.startSoterAuthentication`
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E7%94%9F%E7%89%A9%E8%AE%A4%E8%AF%81&uni-appx=1
)
-
生物识别:指纹识别。
`uni.startSoterAuthentication`
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E7%94%9F%E7%89%A9%E8%AE%A4%E8%AF%81&uni-appx=1
)
-
震动:
`uni.vibrate`
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E9%9C%87%E5%8A%A8&uni-appx=1
)
-
自定义相机:
`uni.createCameraContext`
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E7%9B%B8%E6%9C%BA&uni-appx=1
)
-
自定义相机:
`uni.createCameraContext`
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E7%9B%B8%E6%9C%BA&uni-appx=1
)
-
录音:
`uni.getRecorderManager`
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E5%BD%95%E9%9F%B3&uni-appx=1
)
-
录音:
`uni.getRecorderManager`
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E5%BD%95%E9%9F%B3&uni-appx=1
)
-
播放音频:
`uni.getBackgroundAudioManager`
、
`uni.createInnerAudioContext`
,
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E9%9F%B3%E9%A2%91%E6%92%AD%E6%94%BE&orderBy=Relevance&uni-appx=1
)
或参考如下代码:
-
播放音频:
`uni.getBackgroundAudioManager`
、
`uni.createInnerAudioContext`
,
[
见插件市场
](
https://ext.dcloud.net.cn/search?q=%E9%9F%B3%E9%A2%91%E6%92%AD%E6%94%BE&orderBy=Relevance&uni-appx=1
)
或参考如下代码:
...
...
docs/api/get-current-pages.md
浏览文件 @
5d7042c5
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
支持 pages.json 下
`globalStyle`
节点属性和页面下
`style`
节点属性
支持 pages.json 下
`globalStyle`
节点属性和页面下
`style`
节点属性
当前版本仅支持
的属性,后续实现其他属性
当前版本仅支持
设置如下属性,其他属性未测试。
|属性 |类型 |Android|iOS |web |默认值 |描述 |
|属性 |类型 |Android|iOS |web |默认值 |描述 |
|:-: |:-: |:-: |:-: |:-: |:-: |:-: |
|:-: |:-: |:-: |:-: |:-: |:-: |:-: |
...
@@ -18,8 +18,9 @@
...
@@ -18,8 +18,9 @@
|backgroundColorContent |string |4.15 |4.15 |x |#ffffff|页面容器背景色 |
|backgroundColorContent |string |4.15 |4.15 |x |#ffffff|页面容器背景色 |
**注意事项**
**注意事项**
-
app-ios平台:在page.json 中设置页面
`enablePullDownRefresh`
为
`false`
时,无法通过
`$setPageStyle`
方法动态开启页面下拉刷新 (app-ios平台在
`HBuilderX-4.15`
版本已修复该问题)
-
web端由于会自动摇树优化未使用的特性,如果整个项目中都没有使用到下拉刷新
`enablePullDownRefresh`
,那么下拉刷新功能会被摇掉,此时设置打开下拉刷新将无效。
-
web端由于会自动优化未使用的特性,如果整个项目中都没有使用到
`enablePullDownRefresh`
,那么此属性也无法动态切换
-
4.15版本前,app-ios平台在page.json 中设置页面
`enablePullDownRefresh`
为
`false`
时,无法通过
`$setPageStyle`
方法动态开启页面下拉刷新。新版已修复该问题。
<!-- UTSAPIJSON.getCurrentPages.example -->
<!-- UTSAPIJSON.getCurrentPages.example -->
...
...
docs/tutorial/request.md
浏览文件 @
5d7042c5
...
@@ -318,5 +318,5 @@ hx的json转type工具,会对一些敏感符合和关键字自动转义。但
...
@@ -318,5 +318,5 @@ hx的json转type工具,会对一些敏感符合和关键字自动转义。但
## 注意事项
## 注意事项
*
request 接口内部通过
[
特殊方式读取了范型类型
](
../uts/generics.md#使用限制
)
,不支持传入动态的范型:比如将外层方法的普通范型参数传入 request。所以目前尽量直接使用uni.request而不是封装。如确需封装,可不使用type,改用UTSJSONObject。
*
request 接口内部通过
[
特殊方式读取了范型类型
](
../uts/generics.md#使用限制
)
,不支持传入动态的范型:比如将外层方法的普通范型参数传入 request。所以目前尽量直接使用uni.request而不是封装。如确需封装,可不使用type,改用UTSJSONObject。
*
web端request接口目前没有返回UTSJSONObject类型数据而是一个普通对象,后续可能会调整为UTSJSONObject类型,如需兼容多端可以使用下标获取request返回的数据内容
。
*
4.01及之后版本web端request接口在dataType为
`json`
时返回UTSJSONObject,此前为普通js对象
。
*
web端request接口目前不支持创建传入的泛型的实例
*
web端request接口目前不支持创建传入的泛型的实例
,即泛型仅作为类型校验使用。
docs/uts/buildin-object-api/global.md
浏览文件 @
5d7042c5
# Global
# Global
##
实例
方法
##
全局
方法
### parseInt(string, radix?)
### parseInt(string, radix?)
...
...
docs/uts/buildin-object-api/timers.md
浏览文件 @
5d7042c5
# Timers
# Timers
##
实例
方法
##
全局
方法
### setInterval(handler, timeout?, ...arguments)
### setInterval(handler, timeout?, ...arguments)
...
@@ -90,3 +90,18 @@
...
@@ -90,3 +90,18 @@
}
}
</script>
</script>
```
```
### Android平台差异
需要注意:JS环境中只有一个线程,所以
`setTimeout/setInterval`
执行任务代码的线程和 调用 setTimeout/setInterval 总是同一个线程。
但是Android平台需要分两种情况:
+
如果在主线程/dom 线程 等具备
`Looper`
环境的线程调用
`setTimeout/setInterval`
: 那么可以确保 任务代码执行的线程 和调用setTimeout/setInterval的线程 是同一个线程。
+
如果在匿名线程等 不具备
`Looper`
环境的线程中调用
`setTimeout/setInterval`
: 任务代码不会和 调用setTimeout/setInterval的线程 保持同一线程。
关于
`Android`
系统
`Looper`
的
[
更多介绍
](
https://developer.android.com/reference/android/os/Looper
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录