Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
unidocs-uni-app-x-zh
提交
f99a1eeb
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看板
提交
f99a1eeb
编写于
1月 26, 2024
作者:
D
DCloud_LXH
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 更新 js
上级
8fb5ac96
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
2759 addition
and
28 deletion
+2759
-28
docs/.vuepress/utils/cssJson.json
docs/.vuepress/utils/cssJson.json
+1
-1
docs/.vuepress/utils/customTypeJson.json
docs/.vuepress/utils/customTypeJson.json
+1
-1
docs/.vuepress/utils/pagesJson.json
docs/.vuepress/utils/pagesJson.json
+1
-1
docs/.vuepress/utils/utsApiJson.json
docs/.vuepress/utils/utsApiJson.json
+1
-1
docs/.vuepress/utils/utsComJson.json
docs/.vuepress/utils/utsComJson.json
+1
-1
docs/.vuepress/utils/utsJson.json
docs/.vuepress/utils/utsJson.json
+2696
-1
docs/.vuepress/utils/utsUnicloudApiJson.json
docs/.vuepress/utils/utsUnicloudApiJson.json
+1
-1
docs/.vuepress/utils/vueJson.json
docs/.vuepress/utils/vueJson.json
+1
-1
docs/css/README.md
docs/css/README.md
+4
-20
docs/uts/_sidebar.md
docs/uts/_sidebar.md
+1
-0
docs/uts/buildin-object-api/timers.md
docs/uts/buildin-object-api/timers.md
+51
-0
未找到文件。
docs/.vuepress/utils/cssJson.json
浏览文件 @
f99a1eeb
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
docs/.vuepress/utils/customTypeJson.json
浏览文件 @
f99a1eeb
{
"Event"
:{
"name"
:
"## Event"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| eventInit | [UTSJSONObject](/uts/buildin-object-api/utsjsonobject.md) | 是 | - | - |
\n\n
### Event 的属性值 @event-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UTSJSONObject"
:{
"name"
:
"## UTSJSONObject"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
""
,
"methods"
:{
"get"
:{
"name"
:
"#### get(key) @get"
,
"description"
:
"
\n
获取一个 属性,返回类型是any 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| any | 否 |
\n
"
,
"compatibility"
:
"##### get 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[get](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#get)
\n
"
},
"set"
:{
"name"
:
"#### set(key, value) @set"
,
"description"
:
"
\n
获取一个 属性,返回类型是any 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |
\n
| value | any | 是 | - | - |"
,
"returnValue"
:
""
,
"compatibility"
:
"##### set 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[set](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#set)
\n
"
},
"getAny"
:{
"name"
:
"#### getAny(key) @getany"
,
"description"
:
"
\n
获取一个 属性,返回类型是any 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| any | 否 |
\n
"
,
"compatibility"
:
"##### getAny 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getAny](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getAny)
\n
"
},
"getBoolean"
:{
"name"
:
"#### getBoolean(key) @getboolean"
,
"description"
:
"
\n
获取一个Boolean属性,返回类型是Boolean 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| boolean | 否 |
\n
"
,
"compatibility"
:
"##### getBoolean 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getBoolean](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getBoolean)
\n
"
},
"getNumber"
:{
"name"
:
"#### getNumber(key) @getnumber"
,
"description"
:
"
\n
获取一个number属性,返回类型是number 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| number | 否 |
\n
"
,
"compatibility"
:
"##### getNumber 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getNumber](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getNumber)
\n
"
},
"getString"
:{
"name"
:
"#### getString(key) @getstring"
,
"description"
:
"
\n
获取一个string属性,返回类型是string 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| string | 否 |
\n
"
,
"compatibility"
:
"##### getString 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getString](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getString)
\n
"
},
"getJSON"
:{
"name"
:
"#### getJSON(key) @getjson"
,
"description"
:
"
\n
获取一个UTSJSONObject属性,返回类型是UTSJSONObject 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UTSJSONObject](/uts/buildin-object-api/utsjsonobject.md) | 否 |
\n
"
,
"compatibility"
:
"##### getJSON 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getJSON](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getJSON)
\n
"
},
"getArray"
:{
"name"
:
"#### getArray(key) @getarray"
,
"description"
:
"
\n
获取一个Array属性,返回类型是Array 或者 null, 数组元素类型由泛型T决定"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| T[
\\
] | 否 |
\n
"
,
"compatibility"
:
"##### getArray 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getArray](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getArray<T>)
\n
"
},
"toMap"
:{
"name"
:
"#### toMap() @tomap"
,
"description"
:
"
\n
将当前 UTSJSONObject 实例转换为 Map 实例。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Map
\\
<string, any> |
\n
"
,
"compatibility"
:
"##### toMap 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[toMap](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#toMap)
\n
"
}}},
"UniElement"
:{
"name"
:
"## UniElement"
,
"description"
:
"
\n
UVUE DOM 元素对象,描述了 UVUE DOM 元素所普通具有的属性和方法。"
,
"extends"
:
""
,
"param"
:
"
\n
### UniElement 的属性值 @unielement-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| classList | Array
\\
<string
\\
> | 是 | - | 只读属性 获取当前元素的的 class 属性的动态集合。 |
\n
| firstChild | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的的第一个子元素,如果元素是无子元素,则返回 null。 |
\n
| lastChild | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的最后一个子元素,如果没有子元素,则返回 null。 |
\n
| parentElement | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素在 DOM 树中的父元素,如果没有父元素(如未添加到DOM树中),则返回null。 |
\n
| previousSibling | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的前一个同级元素,没有则返回null。 |
\n
| nextElementSibling | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取在 DOM 树中紧跟在其后面的同级元素,如果指定的元素为最后一个元素,则返回 null。 |
\n
| children | Array
\\
<[UniElement](/dom/unielement.md)
\\
> | 是 | - | 只读属性 获取当前元素包含的子元素的集合 |
\n
| tagName | string | 是 | - | 只读属性 获取当前元素的标签名 |
\n
| dataset | Map
\\
<string, any> | 是 | - | 只读属性 获取元素上自定义数据属性(data-*)的集合 |
\n
| attributes | Map
\\
<string, any> | 是 | - | 只读属性 获取元素上所有属性元素的集合 |
\n
| style | [CSSStyleDeclaration](/dom/cssstyledeclaration.md) | 是 | - | 只读属性 获取元素的CSS样式对象 |
\n
| scrollWidth | number | 是 | - | 只读属性 获取可滚动元素内容的总宽度,仅scroll-view、list-view组件支持,其他组件返回视图宽度 |
\n
| scrollHeight | number | 是 | - | 只读属性 获取可滚动元素内容的总高度,仅scroll-view、list-view组件支持,其他组件返回视图高度 |
\n
| scrollLeft | number | 是 | - | 获取或修改元素滚动条到元素左边的距离像素数,仅scroll-view、list-view组件支持。其他组件返回0 |
\n
| scrollTop | number | 是 | - | 获取或修改元素滚动条到元素顶部的距离像素数,仅scroll-view、list-view组件支持。其他组件返回0 |
\n
| offsetLeft | number | 是 | - | 只读属性 元素的左边界偏移值 单位px |
\n
| offsetTop | number | 是 | - | 只读属性 元素的顶部边界偏移值 单位px |
\n
| offsetWidth | number | 是 | - | 只读属性 元素的布局宽度,宽度包含border、padding的数据值 单位px |
\n
| offsetHeight | number | 是 | - | 只读属性 元素的布局高度,高度包含border、padding的数据值 单位px |
\n
| ext | Map
\\
<string, any> | 是 | - | 只读属性 扩展属性 |
\n
"
,
"methods"
:{
"takeSnapshot"
:{
"name"
:
"#### takeSnapshot(options) @takesnapshot"
,
"description"
:
"
\n
对当前组件进行截图,调用此方法会将当前组件(包含子节点)渲染结果导出成图片。
\n
成功会返回图片对应的临时文件路径,目前默认png格式
\n
"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [TakeSnapshotOptions](#takesnapshotoptions-values) | 是 | - | 组件截图的参数对象 |
\n
###### TakeSnapshotOptions 的属性值 @takesnapshotoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 否 |
\"
file
\"
| 截图导出类型,目前仅支持 'file' 保存到临时文件目录 |
\n
| format | string | 否 |
\"
png
\"
| 截图文件格式,目前仅支持 'png' |
\n
| success | (res: [TakeSnapshotSuccess](#takesnapshotsuccess-values)) => void | 否 | - | 接口调用成功的回调函数 |
\n
| fail | (res: [TakeSnapshotFail](#takesnapshotfail-values)) => void | 否 | - | 接口调用失败的回调函数 |
\n
| complete | (res: any) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |
\n\n
###### TakeSnapshotSuccess 的属性值 @takesnapshotsuccess-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFilePath | string | 是 | - | 截图保存的临时文件路径 |
\n\n
###### TakeSnapshotFail 的属性值 @takesnapshotfail-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errMsg | string | 是 | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"##### takeSnapshot 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.93 | x | x |
\n
"
,
"tutorial"
:
""
},
"appendChild"
:{
"name"
:
"#### appendChild(aChild) @appendchild"
,
"description"
:
"
\n
将一个元素添加到指定父元素的子元素列表的末尾处。如果将被插入的元素已经存在于当前文档的文档树中,那么将会它从原先的位置移动到新的位置。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| aChild | [UniElement](/dom/unielement.md) | 是 | - | 插入子元素对象 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"insertBefore"
:{
"name"
:
"#### insertBefore(newChild, refChild?) @insertbefore"
,
"description"
:
"
\n
在参考元素之前插入一个拥有指定父元素的子元素。如果给定的子元素是对文档中现有元素的引用,insertBefore() 会将其从当前位置移动到新位置。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| newChild | [UniElement](/dom/unielement.md) | 是 | - | 插入子元素对象 |
\n
| refChild | [UniElement](/dom/unielement.md) | 否 | - | 已存在父元素的子元素对象 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"setAttribute"
:{
"name"
:
"#### setAttribute(key, value) @setattribute"
,
"description"
:
"
\n
设置指定元素上的某个属性值。如果设置的属性已经存在,则更新该属性值;否则使用指定的名称和值添加一个新的属性。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |
\n
| value | string | 是 | - | 属性值域 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getAttribute"
:{
"name"
:
"#### getAttribute(key) @getattribute"
,
"description"
:
"
\n
获取元素指定的属性值,如果指定的属性不存在则返回null。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| string | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"hasAttribute"
:{
"name"
:
"#### hasAttribute(key) @hasattribute"
,
"description"
:
"
\n
返回改元素是否包含有指定的属性,属性存在则返回true,否则返回false。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| boolean |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeAttribute"
:{
"name"
:
"#### removeAttribute(key) @removeattribute"
,
"description"
:
"
\n
从元素中删除一个属性,如果指定的属性不存在,则不做任何操作,也不会产生错误。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getBoundingClientRect"
:{
"name"
:
"#### getBoundingClientRect() @getboundingclientrect"
,
"description"
:
"
\n
获取元素的大小及其相对于窗口的位置信息。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [DOMRect](/dom/domrect.md) |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getDrawableContext"
:{
"name"
:
"#### getDrawableContext() @getdrawablecontext"
,
"description"
:
"
\n
获取组件的绘制对象,仅uvue页面中的 view 组件支持,其它组件不支持则返回null。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [DrawableContext](/dom/drawablecontext.md) | 否 |
\n
"
,
"compatibility"
:
"##### getDrawableContext 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | x |
\n
"
,
"tutorial"
:
""
},
"addEventListener"
:{
"name"
:
"#### addEventListener(type, callback) @addeventlistener"
,
"description"
:
"
\n
将指定的监听器注册到元素对象上,当该对象触发指定的事件时,指定的回调函数就会被执行。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| callback | (event: T) => R | 是 | - | 事件监听器 T表示event类型,R表示返回值类型 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| UniCallbackWrapper |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeEventListener"
:{
"name"
:
"#### removeEventListener(type, callbackWrapper) @removeeventlistener"
,
"description"
:
"
\n
删除使用 addEventListener 方法添加的事件监听器。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| callbackWrapper | UniCallbackWrapper | 是 | - | 事件监听回调封装类 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeChild"
:{
"name"
:
"#### removeChild(aChild) @removechild"
,
"description"
:
"
\n
从元素中删除一个子元素,返回删除的元素。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| aChild | [UniElement](/dom/unielement.md) | 是 | - | 被删除子元素对象 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"remove"
:{
"name"
:
"#### remove() @remove"
,
"description"
:
"
\n
把元素对象从它所属的 DOM 树中删除。"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"dispatchEvent"
:{
"name"
:
"#### dispatchEvent(type, value) @dispatchevent"
,
"description"
:
"
\n
向一个指定的事件目标派发一个 Event,并以合适的顺序(同步地)调用此事件的监听器回调函数。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| value | [UniEvent](/component/common#unievent) | 是 | - | 事件返回对象 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"scrollTo"
:{
"name"
:
"#### scrollTo(x, y) @scrollto"
,
"description"
:
"
\n
使界面滚动到给定元素的指定坐标位置 仅scroll-view、list-view组件支持"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | x轴要滚动到坐标位置(单位px) |
\n
| y | number | 是 | - | y轴要滚动到坐标位置(单位px) |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"scrollBy"
:{
"name"
:
"#### scrollBy(x, y) @scrollby"
,
"description"
:
"
\n
使得元素滚动一段特定距离 仅scroll-view、list-view组件支持"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | x轴要滚动的距离(单位px) |
\n
| y | number | 是 | - | y轴要滚动的距离(单位px) |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"querySelector"
:{
"name"
:
"#### querySelector(selector) @queryselector"
,
"description"
:
"
\n
返回文档中与指定选择器或选择器组匹配的第一个 Element对象。如果找不到匹配项,则返回null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| selector | string.cssSelectorString | 是 | - | CSS 选择器字符串 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"querySelectorAll"
:{
"name"
:
"#### querySelectorAll(selector) @queryselectorall"
,
"description"
:
"
\n
返回与指定的选择器组匹配的文档中的元素列表"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| selector | string.cssSelectorString | 是 | - | CSS 选择器字符串 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| Array
\\
<[UniElement](/dom/unielement.md)
\\
> | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"focus"
:{
"name"
:
"#### focus() @focus"
,
"description"
:
"
\n
使元素获取焦点 仅input、Textarea组件支持"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"blur"
:{
"name"
:
"#### blur() @blur"
,
"description"
:
"
\n
使元素丢失焦点 仅input、Textarea组件支持"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"CSSStyleDeclaration"
:{
"name"
:
"## CSSStyleDeclaration"
,
"description"
:
"
\n
CSSStyleDeclaration表示一个CSS 声明块对象,它是一个 CSS 属性键值对的集合,暴露样式信息和各种与样式相关的方法和属性。"
,
"extends"
:
""
,
"param"
:
""
,
"methods"
:{
"setProperty"
:{
"name"
:
"#### setProperty(name, value?) @setproperty"
,
"description"
:
"
\n
对CSS指定样式设置一个新值,如有此样式已存在则更新。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string (string.cssPropertyString) | 是 | - | CSS样式名称 |
\n
| value | any | 否 | - | 要设置的新CSS样式值 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getPropertyValue"
:{
"name"
:
"#### getPropertyValue(property) @getpropertyvalue"
,
"description"
:
"
\n
获取CSS指定的样式值,如果指定的样式不存在则返回null。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| property | string (string.cssPropertyString) | 是 | - | 要获取的CSS样式名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| any | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeProperty"
:{
"name"
:
"#### removeProperty(property) @removeproperty"
,
"description"
:
""
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| property | string (string.cssPropertyString) | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| any | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getStyleMap"
:{
"name"
:
"#### getStyleMap() @getstylemap"
,
"description"
:
""
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Map
\\
<String, any> |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"TakeSnapshotOptions"
:{
"name"
:
"## TakeSnapshotOptions"
,
"description"
:
"
\n
组件截图的参数配置选项"
,
"extends"
:
""
,
"param"
:
"
\n
### TakeSnapshotOptions 的属性值 @takesnapshotoptions-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 否 |
\"
file
\"
| 截图导出类型,目前仅支持 'file' 保存到临时文件目录 |
\n
| format | string | 否 |
\"
png
\"
| 截图文件格式,目前仅支持 'png' |
\n
"
,
"methods"
:{
"success"
:{
"name"
:
"#### success(res) @success"
,
"description"
:
"
\n
接口调用成功的回调函数"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| res | [TakeSnapshotSuccess](#takesnapshotsuccess-values) | 是 | - | - |
\n
###### TakeSnapshotSuccess 的属性值 @takesnapshotsuccess-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFilePath | string | 是 | - | 截图保存的临时文件路径 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"fail"
:{
"name"
:
"#### fail(res) @fail"
,
"description"
:
"
\n
接口调用失败的回调函数"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| res | [TakeSnapshotFail](#takesnapshotfail-values) | 是 | - | - |
\n
###### TakeSnapshotFail 的属性值 @takesnapshotfail-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errMsg | string | 是 | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"complete"
:{
"name"
:
"#### complete(res) @complete"
,
"description"
:
"
\n
接口调用结束的回调函数(调用成功、失败都会执行)"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| res | any | 是 | - | - |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"TakeSnapshotSuccessCallback"
:{
"name"
:
"## TakeSnapshotSuccessCallback"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
""
},
"TakeSnapshotSuccess"
:{
"name"
:
"## TakeSnapshotSuccess"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### TakeSnapshotSuccess 的属性值 @takesnapshotsuccess-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFilePath | string | 是 | - | 截图保存的临时文件路径 |
\n
"
},
"TakeSnapshotFailCallback"
:{
"name"
:
"## TakeSnapshotFailCallback"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
""
},
"TakeSnapshotFail"
:{
"name"
:
"## TakeSnapshotFail"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### TakeSnapshotFail 的属性值 @takesnapshotfail-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errMsg | string | 是 | - | - |
\n
"
},
"TakeSnapshotCompleteCallback"
:{
"name"
:
"## TakeSnapshotCompleteCallback"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
""
},
"DOMRect"
:{
"name"
:
"## DOMRect"
,
"description"
:
"
\n
一个 DOMRect 代表一个矩形。"
,
"extends"
:
""
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 否 | - | - |
\n
| y | number | 否 | - | - |
\n
| width | number | 否 | - | - |
\n
| height | number | 否 | - | - |
\n\n
### DOMRect 的属性值 @domrect-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| width | number | 是 | - | 矩形的宽 |
\n
| height | number | 是 | - | 矩形的高 |
\n
| x | number | 是 | - | 矩形原点的x坐标 |
\n
| y | number | 是 | - | 矩形原点的y坐标 |
\n
| left | number | 是 | - | 矩形的左坐标值 |
\n
| right | number | 是 | - | 矩形的右坐标值 |
\n
| top | number | 是 | - | 矩形的顶坐标值 |
\n
| bottom | number | 是 | - | 矩形的底坐标值 |
\n
"
},
"DrawableContext"
:{
"name"
:
"## DrawableContext"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### DrawableContext 的属性值 @drawablecontext-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| font | string | 是 | 10px | 设置字体大小 |
\n
| fillStyle | string.ColorString | 是 | #000 (黑色) | 设置填充颜色 |
\n
| lineCap | string | 是 | butt | 指定如何绘制每一条线条末端的属性,可选值:`butt`线段末端以方形结束;`round`线段末端以圆形结束;`square`线段末端以方形结束,但是会增加一个一半宽度的矩形区域。 |
\n
| lineDashOffset | number | 是 | - | 设置虚线偏移量 |
\n
| lineJoin | string | 是 | miter | 设置 2 个长度不为 0 的线条相连部分如何连接在一起的属性,可选值:`bevel`斜角;`round`圆角;`miter`尖角。 |
\n
| lineWidth | number | 是 | 1px | 设置线条的宽度 |
\n
| strokeStyle | string.ColorString | 是 | #000 (黑色) | 设置边框的颜色 |
\n
| textAlign | string | 是 | left | 设置文本的对齐方式,可取值:`left`左对齐;`center`居中对齐;`right`右对齐。 |
\n
"
,
"methods"
:{
"beginPath"
:{
"name"
:
"#### beginPath() @beginpath"
,
"description"
:
"
\n
创建一个新的空路径"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"arc"
:{
"name"
:
"#### arc(x, y, radius, startAngle, endAngle, anticlockwise?) @arc"
,
"description"
:
"
\n
绘制一段弧线"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 圆心的X轴坐标 |
\n
| y | number | 是 | - | 圆心的Y轴坐标 |
\n
| radius | number | 是 | - | 圆弧的半径 |
\n
| startAngle | number | 是 | - | 圆弧的起始点,x 轴方向开始计算,单位为弧度 |
\n
| endAngle | number | 是 | - | 圆弧的终点,单位为弧度 |
\n
| anticlockwise | boolean | 否 | true | 圆弧绘制方向,true:逆时针绘制,false:顺时针绘制。 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"moveTo"
:{
"name"
:
"#### moveTo(x, y) @moveto"
,
"description"
:
"
\n
将一个新的路径的起始点移动到 (x,y) 坐标"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 点的X轴坐标 |
\n
| y | number | 是 | - | 点的Y轴坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"rect"
:{
"name"
:
"#### rect(x, y, width, height) @rect"
,
"description"
:
"
\n
创建一个矩形路径"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 矩形起点的X轴坐标 |
\n
| y | number | 是 | - | 矩形起点的Y轴坐标 |
\n
| width | number | 是 | - | 矩形宽度 |
\n
| height | number | 是 | - | 矩形高度 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"lineTo"
:{
"name"
:
"#### lineTo(x, y) @lineto"
,
"description"
:
"
\n
将路径的最后一个点连接到 (x,y) 坐标"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 线终点的X轴坐标 |
\n
| y | number | 是 | - | 线终点的Y轴坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"closePath"
:{
"name"
:
"#### closePath() @closepath"
,
"description"
:
"
\n
闭合路径,将最后一个点与起点连接起来。如果图形已经封闭,或者只有一个点,那么此方法不会产生任何效果。"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"stroke"
:{
"name"
:
"#### stroke() @stroke"
,
"description"
:
"
\n
绘制当前或已经存在的路径的边框。"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"strokeRect"
:{
"name"
:
"#### strokeRect(x, y, width, height) @strokerect"
,
"description"
:
"
\n
绘制一个矩形框"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 矩形起点的X轴坐标 |
\n
| y | number | 是 | - | 矩形起点的Y轴坐标 |
\n
| width | number | 是 | - | 矩形宽度 |
\n
| height | number | 是 | - | 矩形高度 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"strokeText"
:{
"name"
:
"#### strokeText(text, x, y) @stroketext"
,
"description"
:
"
\n
绘制空心字符"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| text | string | 是 | - | 要绘制的字符 |
\n
| x | number | 是 | - | 字符开始绘制的X轴坐标 |
\n
| y | number | 是 | - | 字符开始绘制的Y轴坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"fill"
:{
"name"
:
"#### fill(fillRule?) @fill"
,
"description"
:
"
\n
填充当前或已存在的路径"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| fillRule | string | 否 | nonzero | 填充规则。可取值:`nonzero`非零环绕规则;`evenodd`奇偶环绕规则。 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"fillRect"
:{
"name"
:
"#### fillRect(x, y, width, height) @fillrect"
,
"description"
:
"
\n
绘制一个实心矩形"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 矩形起点的X轴坐标 |
\n
| y | number | 是 | - | 矩形起点的Y轴坐标 |
\n
| width | number | 是 | - | 矩形宽度 |
\n
| height | number | 是 | - | 矩形高度 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"fillText"
:{
"name"
:
"#### fillText(text, x, y) @filltext"
,
"description"
:
"
\n
绘制实心字符"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| text | string | 是 | - | 要绘制的字符 |
\n
| x | number | 是 | - | 字符开始绘制的X轴坐标 |
\n
| y | number | 是 | - | 字符开始绘制的Y轴坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"reset"
:{
"name"
:
"#### reset() @reset"
,
"description"
:
"
\n
清空绘制数据"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"update"
:{
"name"
:
"#### update() @update"
,
"description"
:
"
\n
将所有绘制内容更新到画布上"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"setLineDash"
:{
"name"
:
"#### setLineDash(segments) @setlinedash"
,
"description"
:
"
\n
设置虚线样式"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| segments | number[
\\
] | 是 | - | 一组描述交替绘制线段和间距长度的数字。 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"bezierCurveTo"
:{
"name"
:
"#### bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) @beziercurveto"
,
"description"
:
"
\n
创建三次方贝塞尔曲线路径"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| cp1x | number | 是 | - | 第一个贝塞尔控制点的 x 坐标 |
\n
| cp1y | number | 是 | - | 第一个贝塞尔控制点的 y 坐标 |
\n
| cp2x | number | 是 | - | 第二个贝塞尔控制点的 x 坐标 |
\n
| cp2y | number | 是 | - | 第二个贝塞尔控制点的 y 坐标 |
\n
| x | number | 是 | - | 结束点的 x 坐标 |
\n
| y | number | 是 | - | 结束点的 y 坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}},
"example"
:
"### 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/element-draw/element-draw.uvue)
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<view class=
\"
drawing
\"
id=
\"
draw-text-view
\"
></view>
\n
<view class=
\"
drawing
\"
id=
\"
draw-line-view
\"
></view>
\n
<view class=
\"
drawing
\"
id=
\"
draw-circle-view
\"
></view>
\n
<view class=
\"
drawing
\"
id=
\"
draw-dash-line
\"
></view>
\n
<view class=
\"
drawing
\"
id=
\"
draw-house
\"
></view>
\n
<view class=
\"
drawing
\"
id=
\"
draw-style
\"
></view>
\n
<view class=
\"
drawing
\"
id=
\"
draw-odd
\"
></view>
\n
<view class=
\"
drawing
\"
id=
\"
draw-arcto
\"
></view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n
<script>
\n
var y = 160
\n
export default {
\n
data() {
\n
return {
\n
texts: [
\n
'HBuilderX,轻巧、极速,极客编辑器',
\n
'uni-app x,终极跨平台方案',
\n
'uniCloud,js serverless云服务',
\n
'uts,大一统语言',
\n
'uniMPSdk,让你的App具备小程序能力',
\n
'uni-admin,开源、现成的全端管理后台',
\n
'uni-id,开源、全端的账户中心',
\n
'uni-pay,开源、云端一体、全平台的支付',
\n
'uni-ai,聚合ai能力',
\n
'uni-cms,开源、云端一体、全平台的内容管理平台',
\n
'uni-im,开源、云端一体、全平台的im即时消息',
\n
'uni统计,开源、完善、全平台的统计报表',
\n
'......'
\n
] as string[]
\n
}
\n
},
\n
onShow() {
\n
},
\n\n
onReady() {
\n
this.drawText()
\n
this.drawLines()
\n
this.drawCircles()
\n
this.drawStar()
\n
this.drawhouse()
\n
this.drawPoint()
\n
this.drawRect()
\n
this.drawArcTo()
\n
},
\n
onUnload() {
\n
y = 160
\n
},
\n
methods: {
\n
drawText() {
\n
let element = uni.getElementById('draw-text-view')!
\n
let ctx = element.getDrawableContext()!
\n
let width = element.getBoundingClientRect().width
\n
ctx.reset()
\n
ctx.font =
\"
15px
\"\n
ctx.textAlign =
\"
center
\"\n
for (var i = 0; i < this.texts.length; i++) {
\n
let value = this.texts[i]
\n
if (i % 2 == 0) {
\n
ctx.fillText(value, width / 2, (20 * (i + 1)))
\n
} else {
\n
ctx.strokeText(value, width / 2, (20 * (i + 1)))
\n
}
\n
}
\n
ctx.update()
\n
},
\n
drawLines() {
\n
let ctx = uni.getElementById('draw-line-view')!.getDrawableContext()!
\n
ctx.reset()
\n
ctx.lineWidth = 10;
\n\n
[
\"
round
\"
,
\"
bevel
\"
,
\"
miter
\"
].forEach((join, i) => {
\n
ctx.lineJoin = join;
\n
ctx.beginPath();
\n
ctx.moveTo(5, 10 + i * 40);
\n
ctx.lineTo(50, 50 + i * 40);
\n
ctx.lineTo(90, 10 + i * 40);
\n
ctx.lineTo(130, 50 + i * 40);
\n
ctx.lineTo(170, 10 + i * 40);
\n
ctx.stroke();
\n
});
\n
ctx.lineWidth = 1
\n
var space = 170
\n
ctx.strokeStyle = '#09f';
\n
ctx.beginPath();
\n
ctx.moveTo(10 + space, 10);
\n
ctx.lineTo(140 + space, 10);
\n
ctx.moveTo(10 + space, 140);
\n
ctx.lineTo(140 + space, 140);
\n
ctx.stroke();
\n
// Draw lines
\n
ctx.strokeStyle = 'black';
\n
['butt', 'round', 'square'].forEach((lineCap, i) => {
\n
ctx.lineWidth = 15;
\n
ctx.lineCap = lineCap;
\n
ctx.beginPath();
\n
ctx.moveTo(25 + space + i * 50, 10);
\n
ctx.lineTo(25 + space + i * 50, 140);
\n
ctx.stroke();
\n
});
\n
ctx.lineWidth = 1;
\n
this.drawDashedLine([], ctx);
\n
this.drawDashedLine([2, 2], ctx);
\n
this.drawDashedLine([10, 10], ctx);
\n
this.drawDashedLine([20, 5], ctx);
\n
this.drawDashedLine([15, 3, 3, 3], ctx);
\n
this.drawDashedLine([20, 3, 3, 3, 3, 3, 3, 3], ctx);
\n
ctx.lineDashOffset = 18;
\n
this.drawDashedLine([12, 3, 3], ctx);
\n
ctx.lineDashOffset = 0
\n
ctx.setLineDash([0])
\n
ctx.update()
\n
},
\n
drawDashedLine(pattern : Array<number>, ctx : DrawableContext) {
\n
ctx.beginPath();
\n
ctx.setLineDash(pattern);
\n
ctx.moveTo(0, y);
\n
ctx.lineTo(300, y);
\n
ctx.stroke();
\n
y += 15;
\n
},
\n
drawCircles() {
\n
let ctx = uni.getElementById('draw-circle-view')!.getDrawableContext()!
\n
ctx.reset()
\n
// Draw shapes
\n
for (var i = 0; i < 4; i++) {
\n
for (var j = 0; j < 3; j++) {
\n
ctx.beginPath();
\n
var x = 25 + j * 50; // x coordinate
\n
var y = 25 + i * 50; // y coordinate
\n
var radius = 20; // Arc radius
\n
var startAngle = 0; // Starting point on circle
\n
var endAngle = Math.PI + (Math.PI * j) / 2; // End point on circle
\n
var clockwise = i % 2 == 0 ? false : true; // clockwise or anticlockwise
\n\n
ctx.arc(x, y, radius, startAngle, endAngle, clockwise);
\n\n
if (i > 1) {
\n
ctx.fill();
\n
} else {
\n
ctx.stroke();
\n
}
\n
}
\n
}
\n
ctx.update()
\n
},
\n\n
drawStar() {
\n
let ctx = uni.getElementById('draw-dash-line')!.getDrawableContext()!
\n
ctx.reset()
\n
ctx.beginPath();
\n
var horn = 5; // 画5个角
\n
var angle = 360 / horn; // 五个角的度数
\n
// 两个圆的半径
\n
var R = 50;
\n
var r = 20;
\n
// 坐标
\n
var x = 100;
\n
var y = 100;
\n
for (var i = 0; i < horn; i++) {
\n
// 角度转弧度:角度/180*Math.PI
\n
// 外圆顶点坐标
\n
ctx.lineTo(Math.cos((18 + i * angle) / 180.0 * Math.PI) * R + x, -Math.sin((18 + i * angle) / 180.0 * Math.PI) * R + y);
\n
// 內圆顶点坐标
\n
ctx.lineTo(Math.cos((54 + i * angle) / 180.0 * Math.PI) * r + x, -Math.sin((54 + i * angle) / 180.0 * Math.PI) * r + y);
\n
}
\n
// closePath:关闭路径,将路径的终点与起点相连
\n
ctx.closePath();
\n
ctx.lineWidth = 3;
\n
ctx.fillStyle = '#E4EF00';
\n
ctx.strokeStyle =
\"
red
\"
;
\n
ctx.fill();
\n
ctx.stroke();
\n\n
ctx.lineWidth = 10;
\n
ctx.beginPath()
\n
ctx.moveTo(170, 100)
\n
ctx.lineTo(255, 15)
\n
ctx.lineTo(340, 100)
\n
ctx.closePath()
\n
ctx.fill()
\n
ctx.strokeStyle =
\"
blue
\"\n
ctx.stroke()
\n
ctx.beginPath()
\n
ctx.moveTo(170, 145)
\n
ctx.lineTo(255, 45)
\n
ctx.lineTo(340, 145)
\n
ctx.closePath()
\n
ctx.fill()
\n
ctx.strokeStyle =
\"
gray
\"\n
ctx.stroke()
\n
// 未设置beginPath,导致上下表现一致,与前端一致
\n
ctx.moveTo(170, 190)
\n
ctx.lineTo(255, 90)
\n
ctx.lineTo(340, 190)
\n
ctx.closePath()
\n
ctx.fillStyle =
\"
orange
\"\n
ctx.fill()
\n
ctx.strokeStyle =
\"
khaki
\"\n
ctx.stroke()
\n
ctx.update()
\n
},
\n
hex(num : number) : string {
\n
if (num == 0) {
\n
return
\"
00
\"\n
}
\n
let hexChars =
\"
0123456789ABCDEF
\"
;
\n
let result =
\"\"
;
\n
while (num > 0) {
\n
let remainder = Math.floor(num) % 16;
\n
result = hexChars[remainder] + result;
\n
num = Math.floor(Math.floor(num) / 16);
\n
}
\n
if (result.length == 1) {
\n
return
\"
0
\"
+ result
\n
}
\n
return result
\n
},
\n
drawhouse() {
\n
let ctx = uni.getElementById('draw-house')!.getDrawableContext()!
\n
ctx.reset()
\n
ctx.lineWidth = 10;
\n\n
// Wall
\n
ctx.strokeRect(75, 140, 150, 110);
\n\n
// Door
\n
ctx.fillRect(130, 190, 40, 60);
\n\n
// Roof
\n
ctx.beginPath();
\n
ctx.moveTo(50, 140);
\n
ctx.lineTo(150, 60);
\n
ctx.lineTo(250, 140);
\n
ctx.closePath();
\n
ctx.stroke();
\n
ctx.update()
\n
},
\n
drawPoint() {
\n
let ctx = uni.getElementById('draw-style')!.getDrawableContext()!
\n
ctx.reset()
\n
for (let i = 0; i < 6; i++) {
\n
for (let j = 0; j < 6; j++) {
\n
ctx.strokeStyle = `rgb(0,${Math.floor(255 - 42.5 * i)},${Math.floor(255 - 42.5 * j)})`;
\n
ctx.beginPath();
\n
ctx.arc(12.5 + j * 25, 12.5 + i * 25, 10, 0, Math.PI * 2, true);
\n
ctx.stroke();
\n
}
\n
}
\n
for (let i = 0; i < 6; i++) {
\n
for (let j = 0; j < 6; j++) {
\n
ctx.fillStyle = `rgb(${Math.floor(255 - 42.5 * i)},${Math.floor(255 - 42.5 * j)},0)`;
\n
ctx.fillRect(180 + j * 25, i * 25, 25, 25);
\n
}
\n
}
\n
ctx.update()
\n
},
\n
drawRect() {
\n
let ctx = uni.getElementById('draw-odd')!.getDrawableContext()!
\n
ctx.reset()
\n
// Create path
\n
ctx.moveTo(30, 90);
\n
ctx.lineTo(110, 20);
\n
ctx.lineTo(240, 130);
\n
ctx.lineTo(60, 130);
\n
ctx.lineTo(190, 20);
\n
ctx.lineTo(270, 90);
\n
ctx.closePath();
\n\n
// Fill path
\n
ctx.fillStyle =
\"
green
\"
;
\n
ctx.fill(
\"
evenodd
\"
);
\n
ctx.update()
\n\n
},
\n
drawArcTo() {
\n
let ctx = uni.getElementById('draw-arcto')!.getDrawableContext()!
\n
ctx.reset()
\n
ctx.beginPath();
\n
ctx.moveTo(50, 20);
\n
ctx.bezierCurveTo(230, 30, 150, 60, 50, 100);
\n
ctx.stroke();
\n\n
ctx.fillStyle =
\"
blue
\"
;
\n
// start point
\n
ctx.fillRect(50, 20, 10, 10);
\n
// end point
\n
ctx.fillRect(50, 100, 10, 10);
\n\n
ctx.fillStyle =
\"
red
\"
;
\n
// control point one
\n
ctx.fillRect(230, 30, 10, 10);
\n
// control point two
\n
ctx.fillRect(150, 70, 10, 10);
\n
ctx.update()
\n
}
\n
}
\n
}
\n
</script>
\n\n
<style>
\n
.drawing {
\n
height: 275px;
\n
background-color: lightgray;
\n
margin-bottom: 15px;
\n
}
\n
</style>
\n\n
```"
},
"UniCallbackWrapper"
:{
"name"
:
"## UniCallbackWrapper"
,
"description"
:
"
\n
事件回调封装类,用于注销监听函数的形参"
,
"extends"
:
""
,
"param"
:
""
},
"UniEvent"
:{
"name"
:
"## UniEvent"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| eventInit | [UTSJSONObject](/uts/buildin-object-api/utsjsonobject.md) | 是 | - | - |
\n\n
### UniEvent 的属性值 @unievent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"CustomEvent"
:{
"name"
:
"## CustomEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- CustomEvent : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| options | any | 是 | - | - |
\n\n
### CustomEvent 的属性值 @customevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| detail | T | 是 | - | - |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"MouseEvent"
:{
"name"
:
"## MouseEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniPointerEvent : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| x | number | 是 | - | - |
\n
| y | number | 是 | - | - |
\n
| clientX | number | 是 | - | - |
\n
| clientY | number | 是 | - | - |
\n
| pageX | number | 是 | - | - |
\n
| pageY | number | 是 | - | - |
\n
| screenX | number | 是 | - | - |
\n
| screenY | number | 是 | - | - |
\n\n
### MouseEvent 的属性值 @mouseevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| clientX | number | 是 | - | 相对于页面可显示区域左边的距离 |
\n
| clientY | number | 是 | - | 相对于页面可显示区域顶部的距离 |
\n
| x | number | 是 | - | 相对于页面可显示区域左边的距离,同`clientX` |
\n
| y | number | 是 | - | 相对于页面可显示区域顶部的距离,同`clientY` |
\n
| pageX | number | 是 | - | 相对于文档左边的距离 |
\n
| pageY | number | 是 | - | 相对于文档顶部的距离 |
\n
| screenX | number | 是 | - | 相对于屏幕左边距离 |
\n
| screenY | number | 是 | - | 相对于屏幕顶部的距离 |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"TouchEvent"
:{
"name"
:
"## TouchEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniTouchEvent : Extend
\n
```"
,
"param"
:
"
\n
### TouchEvent 的属性值 @touchevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| touches | Array
\\
<[UniTouch](#unitouch-values)
\\
> | 是 | - | 当前停留在屏幕中的触摸点信息的数组 |
\n
| changedTouches | Array
\\
<[UniTouch](#unitouch-values)
\\
> | 是 | - | 当前变化的触摸点信息的数组 |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UniTouch"
:{
"name"
:
"## UniTouch"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### UniTouch 的属性值 @unitouch-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| clientX | number | 是 | - | 相对于页面可显示区域左边的距离 |
\n
| clientY | number | 是 | - | 相对于页面可显示区域顶部的距离 |
\n
| identifier | number | 是 | - | 触摸点的标识符。这个值在这根手指所引发的所有事件中保持一致,直到手指抬起。 |
\n
| pageX | number | 是 | - | 相对于文档左边的距离 |
\n
| pageY | number | 是 | - | 相对于文档顶部的距离 |
\n
| screenX | number | 是 | - | 相对于屏幕左边距离 |
\n
| screenY | number | 是 | - | 相对于屏幕顶部的距离 |
\n
| force | number | 否 | - | 返回当前触摸点按下的压力大小 |
\n
"
},
"Touch"
:{
"name"
:
"## Touch"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### Touch 的属性值 @touch-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| clientX | number | 是 | - | 相对于页面可显示区域左边的距离 |
\n
| clientY | number | 是 | - | 相对于页面可显示区域顶部的距离 |
\n
| identifier | number | 是 | - | 触摸点的标识符。这个值在这根手指所引发的所有事件中保持一致,直到手指抬起。 |
\n
| pageX | number | 是 | - | 相对于文档左边的距离 |
\n
| pageY | number | 是 | - | 相对于文档顶部的距离 |
\n
| screenX | number | 是 | - | 相对于屏幕左边距离 |
\n
| screenY | number | 是 | - | 相对于屏幕顶部的距离 |
\n
| force | number | 否 | - | 返回当前触摸点按下的压力大小 |
\n
"
},
"UniCustomEvent"
:{
"name"
:
"## UniCustomEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniCustomEvent : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| options | any | 是 | - | - |
\n\n
### UniCustomEvent 的属性值 @unicustomevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| detail | T | 是 | - | - |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UniMouseEvent"
:{
"name"
:
"## UniMouseEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniPointerEvent : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| x | number | 是 | - | - |
\n
| y | number | 是 | - | - |
\n
| clientX | number | 是 | - | - |
\n
| clientY | number | 是 | - | - |
\n
| pageX | number | 是 | - | - |
\n
| pageY | number | 是 | - | - |
\n
| screenX | number | 是 | - | - |
\n
| screenY | number | 是 | - | - |
\n\n
### UniMouseEvent 的属性值 @unimouseevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| clientX | number | 是 | - | 相对于页面可显示区域左边的距离 |
\n
| clientY | number | 是 | - | 相对于页面可显示区域顶部的距离 |
\n
| x | number | 是 | - | 相对于页面可显示区域左边的距离,同`clientX` |
\n
| y | number | 是 | - | 相对于页面可显示区域顶部的距离,同`clientY` |
\n
| pageX | number | 是 | - | 相对于文档左边的距离 |
\n
| pageY | number | 是 | - | 相对于文档顶部的距离 |
\n
| screenX | number | 是 | - | 相对于屏幕左边距离 |
\n
| screenY | number | 是 | - | 相对于屏幕顶部的距离 |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UniTouchEvent"
:{
"name"
:
"## UniTouchEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniTouchEvent : Extend
\n
```"
,
"param"
:
"
\n
### UniTouchEvent 的属性值 @unitouchevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| touches | Array
\\
<[UniTouch](#unitouch-values)
\\
> | 是 | - | 当前停留在屏幕中的触摸点信息的数组 |
\n
| changedTouches | Array
\\
<[UniTouch](#unitouch-values)
\\
> | 是 | - | 当前变化的触摸点信息的数组 |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"Element"
:{
"name"
:
"## Element"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### Element 的属性值 @element-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| classList | Array
\\
<string
\\
> | 是 | - | 只读属性 获取当前元素的的 class 属性的动态集合。 |
\n
| firstChild | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的的第一个子元素,如果元素是无子元素,则返回 null。 |
\n
| lastChild | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的最后一个子元素,如果没有子元素,则返回 null。 |
\n
| parentElement | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素在 DOM 树中的父元素,如果没有父元素(如未添加到DOM树中),则返回null。 |
\n
| previousSibling | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的前一个同级元素,没有则返回null。 |
\n
| nextElementSibling | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取在 DOM 树中紧跟在其后面的同级元素,如果指定的元素为最后一个元素,则返回 null。 |
\n
| children | Array
\\
<[UniElement](/dom/unielement.md)
\\
> | 是 | - | 只读属性 获取当前元素包含的子元素的集合 |
\n
| tagName | string | 是 | - | 只读属性 获取当前元素的标签名 |
\n
| dataset | Map
\\
<string, any> | 是 | - | 只读属性 获取元素上自定义数据属性(data-*)的集合 |
\n
| attributes | Map
\\
<string, any> | 是 | - | 只读属性 获取元素上所有属性元素的集合 |
\n
| style | [CSSStyleDeclaration](/dom/cssstyledeclaration.md) | 是 | - | 只读属性 获取元素的CSS样式对象 |
\n
| scrollWidth | number | 是 | - | 只读属性 获取可滚动元素内容的总宽度,仅scroll-view、list-view组件支持,其他组件返回视图宽度 |
\n
| scrollHeight | number | 是 | - | 只读属性 获取可滚动元素内容的总高度,仅scroll-view、list-view组件支持,其他组件返回视图高度 |
\n
| scrollLeft | number | 是 | - | 获取或修改元素滚动条到元素左边的距离像素数,仅scroll-view、list-view组件支持。其他组件返回0 |
\n
| scrollTop | number | 是 | - | 获取或修改元素滚动条到元素顶部的距离像素数,仅scroll-view、list-view组件支持。其他组件返回0 |
\n
| offsetLeft | number | 是 | - | 只读属性 元素的左边界偏移值 单位px |
\n
| offsetTop | number | 是 | - | 只读属性 元素的顶部边界偏移值 单位px |
\n
| offsetWidth | number | 是 | - | 只读属性 元素的布局宽度,宽度包含border、padding的数据值 单位px |
\n
| offsetHeight | number | 是 | - | 只读属性 元素的布局高度,高度包含border、padding的数据值 单位px |
\n
| ext | Map
\\
<string, any> | 是 | - | 只读属性 扩展属性 |
\n
"
,
"methods"
:{
"takeSnapshot"
:{
"name"
:
"#### takeSnapshot(options) @takesnapshot"
,
"description"
:
"
\n
对当前组件进行截图,调用此方法会将当前组件(包含子节点)渲染结果导出成图片。
\n
成功会返回图片对应的临时文件路径,目前默认png格式
\n
"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [TakeSnapshotOptions](#takesnapshotoptions-values) | 是 | - | 组件截图的参数对象 |
\n
###### TakeSnapshotOptions 的属性值 @takesnapshotoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 否 |
\"
file
\"
| 截图导出类型,目前仅支持 'file' 保存到临时文件目录 |
\n
| format | string | 否 |
\"
png
\"
| 截图文件格式,目前仅支持 'png' |
\n
| success | (res: [TakeSnapshotSuccess](#takesnapshotsuccess-values)) => void | 否 | - | 接口调用成功的回调函数 |
\n
| fail | (res: [TakeSnapshotFail](#takesnapshotfail-values)) => void | 否 | - | 接口调用失败的回调函数 |
\n
| complete | (res: any) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |
\n\n
###### TakeSnapshotSuccess 的属性值 @takesnapshotsuccess-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFilePath | string | 是 | - | 截图保存的临时文件路径 |
\n\n
###### TakeSnapshotFail 的属性值 @takesnapshotfail-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errMsg | string | 是 | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"##### takeSnapshot 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.93 | x | x |
\n
"
,
"tutorial"
:
""
},
"appendChild"
:{
"name"
:
"#### appendChild(aChild) @appendchild"
,
"description"
:
"
\n
将一个元素添加到指定父元素的子元素列表的末尾处。如果将被插入的元素已经存在于当前文档的文档树中,那么将会它从原先的位置移动到新的位置。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| aChild | [UniElement](/dom/unielement.md) | 是 | - | 插入子元素对象 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"insertBefore"
:{
"name"
:
"#### insertBefore(newChild, refChild?) @insertbefore"
,
"description"
:
"
\n
在参考元素之前插入一个拥有指定父元素的子元素。如果给定的子元素是对文档中现有元素的引用,insertBefore() 会将其从当前位置移动到新位置。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| newChild | [UniElement](/dom/unielement.md) | 是 | - | 插入子元素对象 |
\n
| refChild | [UniElement](/dom/unielement.md) | 否 | - | 已存在父元素的子元素对象 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"setAttribute"
:{
"name"
:
"#### setAttribute(key, value) @setattribute"
,
"description"
:
"
\n
设置指定元素上的某个属性值。如果设置的属性已经存在,则更新该属性值;否则使用指定的名称和值添加一个新的属性。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |
\n
| value | string | 是 | - | 属性值域 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getAttribute"
:{
"name"
:
"#### getAttribute(key) @getattribute"
,
"description"
:
"
\n
获取元素指定的属性值,如果指定的属性不存在则返回null。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| string | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"hasAttribute"
:{
"name"
:
"#### hasAttribute(key) @hasattribute"
,
"description"
:
"
\n
返回改元素是否包含有指定的属性,属性存在则返回true,否则返回false。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| boolean |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeAttribute"
:{
"name"
:
"#### removeAttribute(key) @removeattribute"
,
"description"
:
"
\n
从元素中删除一个属性,如果指定的属性不存在,则不做任何操作,也不会产生错误。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getBoundingClientRect"
:{
"name"
:
"#### getBoundingClientRect() @getboundingclientrect"
,
"description"
:
"
\n
获取元素的大小及其相对于窗口的位置信息。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [DOMRect](/dom/domrect.md) |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getDrawableContext"
:{
"name"
:
"#### getDrawableContext() @getdrawablecontext"
,
"description"
:
"
\n
获取组件的绘制对象,仅uvue页面中的 view 组件支持,其它组件不支持则返回null。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [DrawableContext](/dom/drawablecontext.md) | 否 |
\n
"
,
"compatibility"
:
"##### getDrawableContext 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.9 | x | x |
\n
"
,
"tutorial"
:
""
},
"addEventListener"
:{
"name"
:
"#### addEventListener(type, callback) @addeventlistener"
,
"description"
:
"
\n
将指定的监听器注册到元素对象上,当该对象触发指定的事件时,指定的回调函数就会被执行。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| callback | (event: T) => R | 是 | - | 事件监听器 T表示event类型,R表示返回值类型 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| UniCallbackWrapper |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeEventListener"
:{
"name"
:
"#### removeEventListener(type, callbackWrapper) @removeeventlistener"
,
"description"
:
"
\n
删除使用 addEventListener 方法添加的事件监听器。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| callbackWrapper | UniCallbackWrapper | 是 | - | 事件监听回调封装类 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeChild"
:{
"name"
:
"#### removeChild(aChild) @removechild"
,
"description"
:
"
\n
从元素中删除一个子元素,返回删除的元素。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| aChild | [UniElement](/dom/unielement.md) | 是 | - | 被删除子元素对象 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"remove"
:{
"name"
:
"#### remove() @remove"
,
"description"
:
"
\n
把元素对象从它所属的 DOM 树中删除。"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"dispatchEvent"
:{
"name"
:
"#### dispatchEvent(type, value) @dispatchevent"
,
"description"
:
"
\n
向一个指定的事件目标派发一个 Event,并以合适的顺序(同步地)调用此事件的监听器回调函数。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| value | [UniEvent](/component/common#unievent) | 是 | - | 事件返回对象 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"scrollTo"
:{
"name"
:
"#### scrollTo(x, y) @scrollto"
,
"description"
:
"
\n
使界面滚动到给定元素的指定坐标位置 仅scroll-view、list-view组件支持"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | x轴要滚动到坐标位置(单位px) |
\n
| y | number | 是 | - | y轴要滚动到坐标位置(单位px) |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"scrollBy"
:{
"name"
:
"#### scrollBy(x, y) @scrollby"
,
"description"
:
"
\n
使得元素滚动一段特定距离 仅scroll-view、list-view组件支持"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | x轴要滚动的距离(单位px) |
\n
| y | number | 是 | - | y轴要滚动的距离(单位px) |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"querySelector"
:{
"name"
:
"#### querySelector(selector) @queryselector"
,
"description"
:
"
\n
返回文档中与指定选择器或选择器组匹配的第一个 Element对象。如果找不到匹配项,则返回null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| selector | string.cssSelectorString | 是 | - | CSS 选择器字符串 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"querySelectorAll"
:{
"name"
:
"#### querySelectorAll(selector) @queryselectorall"
,
"description"
:
"
\n
返回与指定的选择器组匹配的文档中的元素列表"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| selector | string.cssSelectorString | 是 | - | CSS 选择器字符串 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| Array
\\
<[UniElement](/dom/unielement.md)
\\
> | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"focus"
:{
"name"
:
"#### focus() @focus"
,
"description"
:
"
\n
使元素获取焦点 仅input、Textarea组件支持"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"blur"
:{
"name"
:
"#### blur() @blur"
,
"description"
:
"
\n
使元素丢失焦点 仅input、Textarea组件支持"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UniError"
:{
"name"
:
"## UniError"
,
"description"
:
"
\n
uni api统一错误信息对象 "
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
Error <|-- UniError : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errSubject | string | 是 | - | - |
\n
| errCode | number | 是 | - | - |
\n
| errMsg | string | 是 | - | - |
\n\n
### UniError 的属性值 @unierror-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errSubject | string | 是 | - | 统一错误主题(模块)名称 |
\n
| errCode | number | 是 | - | 统一错误码 |
\n
| errMsg | string | 是 | - | 统一错误描述信息 |
\n
| data | any | 否 | - | 错误信息中包含的数据 |
\n
| cause | [Error](https://uniapp.dcloud.net.cn/tutorial/err-spec.html#unierror) | 否 | - | 源错误信息,可以包含多个错误,详见SourceError |
\n
| name | string | 是 | - | - |
\n
| message | string | 是 | - | - |
\n
"
},
"Error"
:{
"name"
:
"## Error"
,
"description"
:
"
\n
UTS错误信息对象"
,
"extends"
:
""
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| message | string | 是 | - | - |
\n
| options | [UTSJSONObject](/uts/buildin-object-api/utsjsonobject.md) | 是 | - | - |
\n\n
### Error 的属性值 @error-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string | 是 | - | - |
\n
| message | string | 是 | - | - |
\n
| cause | [Error](https://uniapp.dcloud.net.cn/tutorial/err-spec.html#unierror) | 否 | - | - |
\n
"
},
"general-attribute"
:{
"example"
:
"### 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/component/general-attribute/general-attribute.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/component/general-attribute/general-attribute
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view style=
\"
flex: 1
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap container
\"
>
\n
<view
\n
:id=
\"
generalId
\"\n
:class=
\"
generalClass
\"\n
:name=
\"
generalName
\"\n
:title=
\"
generalTitle
\"\n
:data-test=
\"
generalData
\"\n
:style=
\"
generalStyle
\"\n
ref=
\"
general-target
\"\n
>
\n
<text>id: {{ generalId }}</text>
\n
<text>class: {{ generalClass }}</text>
\n
<text>name: {{ generalName }}</text>
\n
<text>title: {{ generalTitle }}</text>
\n
<text>data-test: {{ generalData }}</text>
\n
<text>style: {{ generalStyle }}</text>
\n
</view>
\n
<view
\n
class=
\"
btn btn-style uni-common-mt
\"\n
@click=
\"
validateGeneralAttributes
\"\n
>
\n
<text class=
\"
btn-inner
\"
>{{ validateGeneralAttrText }}</text>
\n
</view>
\n
<view class=
\"
btn btn-ref uni-common-mt
\"
@click=
\"
changeHeight
\"
>
\n
<text class=
\"
btn-inner
\"
>{{changeHeightByRefText}}</text>
\n
</view>
\n
<view class=
\"
view-class
\"
:hover-class=
\"
hoverClass
\"
ref=
\"
view-target
\"
>
\n
<text class=
\"
text
\"
>按下 50 ms 后背景变红</text>
\n
<text class=
\"
text
\"
>抬起 400 ms 后背景恢复</text>
\n
</view>
\n
<view
\n
class=
\"
view-class
\"\n
:hover-class=
\"
hoverClass
\"\n
:hover-start-time=
\"
1000
\"\n
:hover-stay-time=
\"
1000
\"\n
ref=
\"
view-target
\"\n
>
\n
<text class=
\"
text
\"
>按下 1000 ms 后背景变红</text>
\n
<text class=
\"
text
\"
>抬起 1000 ms 后背景恢复</text>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
.btn {
\n
height: 50px;
\n
display: flex;
\n
align-items: center;
\n
justify-content: center;
\n
background-color: #409eff;
\n
border-radius: 5px;
\n
}
\n
.btn-inner {
\n
color: #fff;
\n
}
\n
.general-class {
\n
margin-left: 40px;
\n
padding: 10px;
\n
width: 260px;
\n
height: 160px;
\n
background-color: antiquewhite;
\n
}
\n
.view-class {
\n
margin: 20px 0 0 50px;
\n
padding: 10px;
\n
width: 240px;
\n
height: 100px;
\n
background-color: antiquewhite;
\n
}
\n
.view-class .text {
\n
margin-top: 5px;
\n
text-align: center;
\n
}
\n
.hover-class {
\n
background-color: red;
\n
}
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: 'general-attribute',
\n
generalId: 'general-id',
\n
generalClass: 'general-class',
\n
generalName: 'general-name',
\n
generalTitle: 'general-title',
\n
generalData: 'general-data',
\n
generalStyle: 'background-color: aqua',
\n
validateGeneralAttrText: '验证基础属性',
\n
hoverClass: 'hover-class',
\n
validateViewAttrText: '验证 view 属性',
\n
changeHeightByRefText: '通过 ref 修改高度',
\n
}
\n
},
\n
methods: {
\n
validateGeneralAttributes() {
\n
const generalTarget = this.$refs['general-target'] as UniElement
\n
const generalId = generalTarget.getAttribute('id')
\n
if (generalId != this.generalId) {
\n
this.validateGeneralAttrText = '基础属性 id 验证失败'
\n
return
\n
}
\n
// #ifdef APP
\n
if (!generalTarget.classList.includes('general-class')) {
\n
// #endif
\n
// #ifdef WEB
\n
if (!Array.from(generalTarget.classList).includes('general-class')) {
\n
// #endif
\n
this.validateGeneralAttrText = '基础属性 class 验证失败'
\n
return
\n
}
\n
const generalName = generalTarget.getAttribute('name')
\n
if (generalName != this.generalName) {
\n
this.validateGeneralAttrText = '基础属性 name 验证失败'
\n
return
\n
}
\n
const generalTitle = generalTarget.getAttribute('title')
\n
if (generalTitle != this.generalTitle) {
\n
this.validateGeneralAttrText = '基础属性 title 验证失败'
\n
return
\n
}
\n
const generalData = generalTarget.getAttribute('data-test')
\n
if (generalData != this.generalData) {
\n
this.validateGeneralAttrText = '基础属性 data-test 验证失败'
\n
return
\n
}
\n
this.validateGeneralAttrText = '基础属性验证成功'
\n
},
\n
changeHeight(){
\n
const generalTarget = this.$refs['general-target'] as UniElement
\n
this.changeHeightByRefText = '已通过 ref 修改高度'
\n
generalTarget.style.setProperty('height', '200px')
\n
}
\n
},
\n
}
\n\n
```
\n\n
:::"
},
"general-event"
:{
"example"
:
"### 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/component/general-event/general-event.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/component/general-event/general-event
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view style=
\"
flex: 1
\"
>
\n
<!-- #endif -->
\n
<page-head title=
\"
触摸方块测试相关事件
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt container
\"
>
\n
<view class=
\"
target
\"
@touchstart=
\"
onTouchStart
\"
@touchcancel=
\"
onTouchCancel
\"
@touchmove=
\"
onTouchMove
\"\n
@touchend=
\"
onTouchEnd
\"
@tap=
\"
onTap
\"
@click=
\"
onClick
\"
@longpress=
\"
onLongPress
\"
></view>
\n
<view v-if=
\"
touchStartEvent !== null
\"
>
\n
<text class=
\"
title1
\"
>touchStart Event: </text>
\n
<text class=
\"
title2
\"
>touches: </text>
\n
<template v-for=
\"
(touch, index) in touchStartEvent!.touches
\"
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\n
<template v-for=
\"
(touch, index) in touchStartEvent!.changedTouches
\"
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
</view>
\n
<view v-if=
\"
touchCancelEvent !== null
\"
>
\n
<text class=
\"
title1
\"
>touchCancel Event: </text>
\n
<text class=
\"
title2
\"
>touches: </text>
\n
<template v-for=
\"
(touch, index) in touchCancelEvent!.touches
\"
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\n
<template v-for=
\"
(touch, index) in touchCancelEvent!.changedTouches
\"
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
</view>
\n
<view v-if=
\"
touchMoveEvent !== null
\"
>
\n
<text class=
\"
title1
\"
>touchMove Event: </text>
\n
<text class=
\"
title2
\"
>touches: </text>
\n
<template v-for=
\"
(touch, index) in touchMoveEvent!.touches
\"
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\n
<template v-for=
\"
(touch, index) in touchMoveEvent!.changedTouches
\"
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
</view>
\n
<view v-if=
\"
longPressEvent !== null
\"
>
\n
<text class=
\"
title1
\"
>longPress Event: </text>
\n
<text class=
\"
title2
\"
>touches: </text>
\n
<template v-if=
\"
longPressEvent!.touches.length > 0
\"
v-for=
\"
(touch, index) in longPressEvent!.touches
\"\n
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\n
<template v-for=
\"
(touch, index) in longPressEvent!.changedTouches
\"
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
</view>
\n
<view v-if=
\"
touchEndEvent !== null
\"
>
\n
<text class=
\"
title1
\"
>touchEnd Event: </text>
\n
<text class=
\"
title2
\"
>touches: </text>
\n
<template v-if=
\"
touchEndEvent!.touches.length > 0
\"
v-for=
\"
(touch, index) in touchEndEvent!.touches
\"\n
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\n
<template v-for=
\"
(touch, index) in touchEndEvent!.changedTouches
\"
:key=
\"
index
\"
>
\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\n
<text>identifier: {{touch.identifier}}</text>
\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\n
</template>
\n
</view>
\n
<view v-if=
\"
tapEvent !== null
\"
>
\n
<text class=
\"
title1
\"
>tap Event: </text>
\n
<text>x: {{ tapEvent!.x }}, y: {{ tapEvent!.y }}</text>
\n
</view>
\n
<view v-if=
\"
clickEvent !== null
\"
>
\n
<text class=
\"
title1
\"
>click Event: </text>
\n
<text>x: {{ clickEvent!.x }}, y: {{ clickEvent!.y }}</text>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n
<style>
\n
.container {
\n
padding-bottom: 10px;
\n
}
\n\n
.target {
\n
margin: 20px 0 0 50px;
\n
width: 200px;
\n
height: 100px;
\n
background-color: aqua;
\n
}
\n\n
.title1 {
\n
margin-top: 15px;
\n
font-size: 20px;
\n
}
\n\n
.title2 {
\n
margin-top: 10px;
\n
font-size: 18px;
\n
}
\n\n
.title3 {
\n
margin-top: 5px;
\n
font-size: 16px;
\n
}
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: 'general-event',
\n
onTouchStartTime: 0,
\n
touchStartEvent: null as TouchEvent | null,
\n
touchCancelEvent: null as TouchEvent | null,
\n
onTouchMoveTime: 0,
\n
touchMoveEvent: null as TouchEvent | null,
\n
onTouchEndTime: 0,
\n
longPressEvent: null as TouchEvent | null,
\n
touchEndEvent: null as TouchEvent | null,
\n
onTapTime: 0,
\n
tapEvent: null as PointerEvent | null,
\n
onClickTime: 0,
\n
clickEvent: null as PointerEvent | null,
\n
onLongPressTime: 0,
\n
}
\n
},
\n
methods: {
\n
onTouchStart(e : TouchEvent) {
\n
this.touchStartEvent = e
\n
this.onTouchStartTime = Date.now()
\n
console.log('onTouchStart')
\n
},
\n
onTouchCancel(e : TouchEvent) {
\n
this.touchCancelEvent = e
\n
console.log('onTouchCancel')
\n
},
\n
onTouchMove(e : TouchEvent) {
\n
this.touchMoveEvent = e
\n
this.onTouchMoveTime = Date.now()
\n
console.log('onTouchMove')
\n
},
\n
onLongPress(e : TouchEvent) {
\n
this.longPressEvent = e
\n
this.onLongPressTime = Date.now()
\n
console.log('onLongPress')
\n
},
\n
onTouchEnd(e : TouchEvent) {
\n
this.touchEndEvent = e
\n
this.onTouchEndTime = Date.now()
\n
console.log('onTouchEnd')
\n
},
\n
onTap(e : PointerEvent) {
\n
this.tapEvent = e
\n
this.onTapTime = Date.now()
\n
console.log('onTap')
\n
},
\n
onClick(e : PointerEvent) {
\n
this.clickEvent = e
\n
this.onClickTime = Date.now()
\n
console.log('onClick')
\n
},
\n
},
\n
}
\n\n
```
\n\n
:::"
}}
\ No newline at end of file
{
"Event"
:{
"name"
:
"## Event"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| eventInit | [UTSJSONObject](/uts/buildin-object-api/utsjsonobject.md) | 是 | - | - |
\n\n
### Event 的属性值 @event-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\r\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\r\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UTSJSONObject"
:{
"name"
:
"## UTSJSONObject"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
""
,
"methods"
:{
"get"
:{
"name"
:
"#### get(key) @get"
,
"description"
:
"
\r\n
获取一个 属性,返回类型是any 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| any | 否 |
\n
"
,
"compatibility"
:
"##### get 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[get](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#get)
\n
"
},
"set"
:{
"name"
:
"#### set(key, value) @set"
,
"description"
:
"
\r\n
获取一个 属性,返回类型是any 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |
\n
| value | any | 是 | - | - |"
,
"returnValue"
:
""
,
"compatibility"
:
"##### set 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[set](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#set)
\n
"
},
"getAny"
:{
"name"
:
"#### getAny(key) @getany"
,
"description"
:
"
\r\n
获取一个 属性,返回类型是any 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| any | 否 |
\n
"
,
"compatibility"
:
"##### getAny 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getAny](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getAny)
\n
"
},
"getBoolean"
:{
"name"
:
"#### getBoolean(key) @getboolean"
,
"description"
:
"
\r\n
获取一个Boolean属性,返回类型是Boolean 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| boolean | 否 |
\n
"
,
"compatibility"
:
"##### getBoolean 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getBoolean](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getBoolean)
\n
"
},
"getNumber"
:{
"name"
:
"#### getNumber(key) @getnumber"
,
"description"
:
"
\r\n
获取一个number属性,返回类型是number 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| number | 否 |
\n
"
,
"compatibility"
:
"##### getNumber 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getNumber](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getNumber)
\n
"
},
"getString"
:{
"name"
:
"#### getString(key) @getstring"
,
"description"
:
"
\r\n
获取一个string属性,返回类型是string 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| string | 否 |
\n
"
,
"compatibility"
:
"##### getString 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getString](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getString)
\n
"
},
"getJSON"
:{
"name"
:
"#### getJSON(key) @getjson"
,
"description"
:
"
\r\n
获取一个UTSJSONObject属性,返回类型是UTSJSONObject 或者 null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UTSJSONObject](/uts/buildin-object-api/utsjsonobject.md) | 否 |
\n
"
,
"compatibility"
:
"##### getJSON 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getJSON](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getJSON)
\n
"
},
"getArray"
:{
"name"
:
"#### getArray(key) @getarray"
,
"description"
:
"
\r\n
获取一个Array属性,返回类型是Array 或者 null, 数组元素类型由泛型T决定"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| T[
\\
] | 否 |
\n
"
,
"compatibility"
:
"##### getArray 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[getArray](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#getArray<T>)
\n
"
},
"toMap"
:{
"name"
:
"#### toMap() @tomap"
,
"description"
:
"
\r\n
将当前 UTSJSONObject 实例转换为 Map 实例。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Map
\\
<string, any> |
\n
"
,
"compatibility"
:
"##### toMap 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | 4.0 |
\n
"
,
"tutorial"
:
"
\n
##### 参见
\n
[toMap](https://uniapp.dcloud.net.cn/uts/buildin-object-api/UTSJSONObject.html#toMap)
\n
"
}}},
"UniElement"
:{
"name"
:
"## UniElement"
,
"description"
:
"
\r\n
UVUE DOM 元素对象,描述了 UVUE DOM 元素所普通具有的属性和方法。"
,
"extends"
:
""
,
"param"
:
"
\n
### UniElement 的属性值 @unielement-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| classList | Array
\\
<string
\\
> | 是 | - | 只读属性 获取当前元素的的 class 属性的动态集合。 |
\n
| firstChild | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的的第一个子元素,如果元素是无子元素,则返回 null。 |
\n
| lastChild | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的最后一个子元素,如果没有子元素,则返回 null。 |
\n
| parentElement | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素在 DOM 树中的父元素,如果没有父元素(如未添加到DOM树中),则返回null。 |
\n
| previousSibling | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的前一个同级元素,没有则返回null。 |
\n
| nextElementSibling | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取在 DOM 树中紧跟在其后面的同级元素,如果指定的元素为最后一个元素,则返回 null。 |
\n
| children | Array
\\
<[UniElement](/dom/unielement.md)
\\
> | 是 | - | 只读属性 获取当前元素包含的子元素的集合 |
\n
| tagName | string | 是 | - | 只读属性 获取当前元素的标签名 |
\n
| dataset | Map
\\
<string, any> | 是 | - | 只读属性 获取元素上自定义数据属性(data-*)的集合 |
\n
| attributes | Map
\\
<string, any> | 是 | - | 只读属性 获取元素上所有属性元素的集合 |
\n
| style | [CSSStyleDeclaration](/dom/cssstyledeclaration.md) | 是 | - | 只读属性 获取元素的CSS样式对象 |
\n
| scrollWidth | number | 是 | - | 只读属性 获取可滚动元素内容的总宽度,仅scroll-view、list-view组件支持,其他组件返回视图宽度 |
\n
| scrollHeight | number | 是 | - | 只读属性 获取可滚动元素内容的总高度,仅scroll-view、list-view组件支持,其他组件返回视图高度 |
\n
| scrollLeft | number | 是 | - | 获取或修改元素滚动条到元素左边的距离像素数,仅scroll-view、list-view组件支持。其他组件返回0 |
\n
| scrollTop | number | 是 | - | 获取或修改元素滚动条到元素顶部的距离像素数,仅scroll-view、list-view组件支持。其他组件返回0 |
\n
| offsetLeft | number | 是 | - | 只读属性 元素的左边界偏移值 单位px |
\n
| offsetTop | number | 是 | - | 只读属性 元素的顶部边界偏移值 单位px |
\n
| offsetWidth | number | 是 | - | 只读属性 元素的布局宽度,宽度包含border、padding的数据值 单位px |
\n
| offsetHeight | number | 是 | - | 只读属性 元素的布局高度,高度包含border、padding的数据值 单位px |
\n
| ext | Map
\\
<string, any> | 是 | - | 只读属性 扩展属性 |
\n
"
,
"methods"
:{
"takeSnapshot"
:{
"name"
:
"#### takeSnapshot(options) @takesnapshot"
,
"description"
:
"
\r\n
对当前组件进行截图,调用此方法会将当前组件(包含子节点)渲染结果导出成图片。
\r\n
成功会返回图片对应的临时文件路径,目前默认png格式
\r\n
"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [TakeSnapshotOptions](#takesnapshotoptions-values) | 是 | - | 组件截图的参数对象 |
\n
###### TakeSnapshotOptions 的属性值 @takesnapshotoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 否 |
\"
file
\"
| 截图导出类型,目前仅支持 'file' 保存到临时文件目录 |
\n
| format | string | 否 |
\"
png
\"
| 截图文件格式,目前仅支持 'png' |
\n
| success | (res: [TakeSnapshotSuccess](#takesnapshotsuccess-values)) => void | 否 | - | 接口调用成功的回调函数 |
\n
| fail | (res: [TakeSnapshotFail](#takesnapshotfail-values)) => void | 否 | - | 接口调用失败的回调函数 |
\n
| complete | (res: any) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |
\n\n
###### TakeSnapshotSuccess 的属性值 @takesnapshotsuccess-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFilePath | string | 是 | - | 截图保存的临时文件路径 |
\n\n
###### TakeSnapshotFail 的属性值 @takesnapshotfail-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errMsg | string | 是 | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"##### takeSnapshot 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.93 | x | x |
\n
"
,
"tutorial"
:
""
},
"appendChild"
:{
"name"
:
"#### appendChild(aChild) @appendchild"
,
"description"
:
"
\r\n
将一个元素添加到指定父元素的子元素列表的末尾处。如果将被插入的元素已经存在于当前文档的文档树中,那么将会它从原先的位置移动到新的位置。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| aChild | [UniElement](/dom/unielement.md) | 是 | - | 插入子元素对象 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"insertBefore"
:{
"name"
:
"#### insertBefore(newChild, refChild?) @insertbefore"
,
"description"
:
"
\r\n
在参考元素之前插入一个拥有指定父元素的子元素。如果给定的子元素是对文档中现有元素的引用,insertBefore() 会将其从当前位置移动到新位置。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| newChild | [UniElement](/dom/unielement.md) | 是 | - | 插入子元素对象 |
\n
| refChild | [UniElement](/dom/unielement.md) | 否 | - | 已存在父元素的子元素对象 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"setAttribute"
:{
"name"
:
"#### setAttribute(key, value) @setattribute"
,
"description"
:
"
\r\n
设置指定元素上的某个属性值。如果设置的属性已经存在,则更新该属性值;否则使用指定的名称和值添加一个新的属性。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |
\n
| value | string | 是 | - | 属性值域 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getAttribute"
:{
"name"
:
"#### getAttribute(key) @getattribute"
,
"description"
:
"
\r\n
获取元素指定的属性值,如果指定的属性不存在则返回null。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| string | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"hasAttribute"
:{
"name"
:
"#### hasAttribute(key) @hasattribute"
,
"description"
:
"
\r\n
返回改元素是否包含有指定的属性,属性存在则返回true,否则返回false。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| boolean |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeAttribute"
:{
"name"
:
"#### removeAttribute(key) @removeattribute"
,
"description"
:
"
\r\n
从元素中删除一个属性,如果指定的属性不存在,则不做任何操作,也不会产生错误。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getBoundingClientRect"
:{
"name"
:
"#### getBoundingClientRect() @getboundingclientrect"
,
"description"
:
"
\r\n
获取元素的大小及其相对于窗口的位置信息。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [DOMRect](/dom/domrect.md) |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getDrawableContext"
:{
"name"
:
"#### getDrawableContext() @getdrawablecontext"
,
"description"
:
"
\r\n
获取组件的绘制对象,仅uvue页面中的 view 组件支持,其它组件不支持则返回null。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [DrawableContext](/dom/drawablecontext.md) | 否 |
\n
"
,
"compatibility"
:
"##### getDrawableContext 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | x |
\n
"
,
"tutorial"
:
""
},
"addEventListener"
:{
"name"
:
"#### addEventListener(type, callback) @addeventlistener"
,
"description"
:
"
\r\n
将指定的监听器注册到元素对象上,当该对象触发指定的事件时,指定的回调函数就会被执行。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| callback | (event: T) => R | 是 | - | 事件监听器 T表示event类型,R表示返回值类型 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| UniCallbackWrapper |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeEventListener"
:{
"name"
:
"#### removeEventListener(type, callbackWrapper) @removeeventlistener"
,
"description"
:
"
\r\n
删除使用 addEventListener 方法添加的事件监听器。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| callbackWrapper | UniCallbackWrapper | 是 | - | 事件监听回调封装类 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeChild"
:{
"name"
:
"#### removeChild(aChild) @removechild"
,
"description"
:
"
\r\n
从元素中删除一个子元素,返回删除的元素。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| aChild | [UniElement](/dom/unielement.md) | 是 | - | 被删除子元素对象 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"remove"
:{
"name"
:
"#### remove() @remove"
,
"description"
:
"
\r\n
把元素对象从它所属的 DOM 树中删除。"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"dispatchEvent"
:{
"name"
:
"#### dispatchEvent(type, value) @dispatchevent"
,
"description"
:
"
\r\n
向一个指定的事件目标派发一个 Event,并以合适的顺序(同步地)调用此事件的监听器回调函数。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| value | [UniEvent](/component/common#unievent) | 是 | - | 事件返回对象 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"scrollTo"
:{
"name"
:
"#### scrollTo(x, y) @scrollto"
,
"description"
:
"
\r\n
使界面滚动到给定元素的指定坐标位置 仅scroll-view、list-view组件支持"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | x轴要滚动到坐标位置(单位px) |
\n
| y | number | 是 | - | y轴要滚动到坐标位置(单位px) |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"scrollBy"
:{
"name"
:
"#### scrollBy(x, y) @scrollby"
,
"description"
:
"
\r\n
使得元素滚动一段特定距离 仅scroll-view、list-view组件支持"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | x轴要滚动的距离(单位px) |
\n
| y | number | 是 | - | y轴要滚动的距离(单位px) |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"querySelector"
:{
"name"
:
"#### querySelector(selector) @queryselector"
,
"description"
:
"
\r\n
返回文档中与指定选择器或选择器组匹配的第一个 Element对象。如果找不到匹配项,则返回null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| selector | string.cssSelectorString | 是 | - | CSS 选择器字符串 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"querySelectorAll"
:{
"name"
:
"#### querySelectorAll(selector) @queryselectorall"
,
"description"
:
"
\r\n
返回与指定的选择器组匹配的文档中的元素列表"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| selector | string.cssSelectorString | 是 | - | CSS 选择器字符串 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| Array
\\
<[UniElement](/dom/unielement.md)
\\
> | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"focus"
:{
"name"
:
"#### focus() @focus"
,
"description"
:
"
\r\n
使元素获取焦点 仅input、Textarea组件支持"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"blur"
:{
"name"
:
"#### blur() @blur"
,
"description"
:
"
\r\n
使元素丢失焦点 仅input、Textarea组件支持"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"CSSStyleDeclaration"
:{
"name"
:
"## CSSStyleDeclaration"
,
"description"
:
"
\r\n
CSSStyleDeclaration表示一个CSS 声明块对象,它是一个 CSS 属性键值对的集合,暴露样式信息和各种与样式相关的方法和属性。"
,
"extends"
:
""
,
"param"
:
""
,
"methods"
:{
"setProperty"
:{
"name"
:
"#### setProperty(name, value?) @setproperty"
,
"description"
:
"
\r\n
对CSS指定样式设置一个新值,如有此样式已存在则更新。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string (string.cssPropertyString) | 是 | - | CSS样式名称 |
\n
| value | any | 否 | - | 要设置的新CSS样式值 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getPropertyValue"
:{
"name"
:
"#### getPropertyValue(property) @getpropertyvalue"
,
"description"
:
"
\r\n
获取CSS指定的样式值,如果指定的样式不存在则返回null。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| property | string (string.cssPropertyString) | 是 | - | 要获取的CSS样式名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| any | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeProperty"
:{
"name"
:
"#### removeProperty(property) @removeproperty"
,
"description"
:
""
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| property | string (string.cssPropertyString) | 是 | - | - |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| any | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getStyleMap"
:{
"name"
:
"#### getStyleMap() @getstylemap"
,
"description"
:
""
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Map
\\
<String, any> |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"TakeSnapshotOptions"
:{
"name"
:
"## TakeSnapshotOptions"
,
"description"
:
"
\r\n
组件截图的参数配置选项"
,
"extends"
:
""
,
"param"
:
"
\n
### TakeSnapshotOptions 的属性值 @takesnapshotoptions-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 否 |
\"
file
\"
| 截图导出类型,目前仅支持 'file' 保存到临时文件目录 |
\n
| format | string | 否 |
\"
png
\"
| 截图文件格式,目前仅支持 'png' |
\n
"
,
"methods"
:{
"success"
:{
"name"
:
"#### success(res) @success"
,
"description"
:
"
\r\n
接口调用成功的回调函数"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| res | [TakeSnapshotSuccess](#takesnapshotsuccess-values) | 是 | - | - |
\n
###### TakeSnapshotSuccess 的属性值 @takesnapshotsuccess-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFilePath | string | 是 | - | 截图保存的临时文件路径 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"fail"
:{
"name"
:
"#### fail(res) @fail"
,
"description"
:
"
\r\n
接口调用失败的回调函数"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| res | [TakeSnapshotFail](#takesnapshotfail-values) | 是 | - | - |
\n
###### TakeSnapshotFail 的属性值 @takesnapshotfail-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errMsg | string | 是 | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"complete"
:{
"name"
:
"#### complete(res) @complete"
,
"description"
:
"
\r\n
接口调用结束的回调函数(调用成功、失败都会执行)"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| res | any | 是 | - | - |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"TakeSnapshotSuccessCallback"
:{
"name"
:
"## TakeSnapshotSuccessCallback"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
""
},
"TakeSnapshotSuccess"
:{
"name"
:
"## TakeSnapshotSuccess"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### TakeSnapshotSuccess 的属性值 @takesnapshotsuccess-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFilePath | string | 是 | - | 截图保存的临时文件路径 |
\n
"
},
"TakeSnapshotFailCallback"
:{
"name"
:
"## TakeSnapshotFailCallback"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
""
},
"TakeSnapshotFail"
:{
"name"
:
"## TakeSnapshotFail"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### TakeSnapshotFail 的属性值 @takesnapshotfail-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errMsg | string | 是 | - | - |
\n
"
},
"TakeSnapshotCompleteCallback"
:{
"name"
:
"## TakeSnapshotCompleteCallback"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
""
},
"DOMRect"
:{
"name"
:
"## DOMRect"
,
"description"
:
"
\r\n
一个 DOMRect 代表一个矩形。"
,
"extends"
:
""
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 否 | - | - |
\n
| y | number | 否 | - | - |
\n
| width | number | 否 | - | - |
\n
| height | number | 否 | - | - |
\n\n
### DOMRect 的属性值 @domrect-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| width | number | 是 | - | 矩形的宽 |
\n
| height | number | 是 | - | 矩形的高 |
\n
| x | number | 是 | - | 矩形原点的x坐标 |
\n
| y | number | 是 | - | 矩形原点的y坐标 |
\n
| left | number | 是 | - | 矩形的左坐标值 |
\n
| right | number | 是 | - | 矩形的右坐标值 |
\n
| top | number | 是 | - | 矩形的顶坐标值 |
\n
| bottom | number | 是 | - | 矩形的底坐标值 |
\n
"
},
"DrawableContext"
:{
"name"
:
"## DrawableContext"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### DrawableContext 的属性值 @drawablecontext-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| font | string | 是 | 10px | 设置字体大小 |
\n
| fillStyle | string.ColorString | 是 | #000 (黑色) | 设置填充颜色 |
\n
| lineCap | string | 是 | butt | 指定如何绘制每一条线条末端的属性,可选值:`butt`线段末端以方形结束;`round`线段末端以圆形结束;`square`线段末端以方形结束,但是会增加一个一半宽度的矩形区域。 |
\n
| lineDashOffset | number | 是 | - | 设置虚线偏移量 |
\n
| lineJoin | string | 是 | miter | 设置 2 个长度不为 0 的线条相连部分如何连接在一起的属性,可选值:`bevel`斜角;`round`圆角;`miter`尖角。 |
\n
| lineWidth | number | 是 | 1px | 设置线条的宽度 |
\n
| strokeStyle | string.ColorString | 是 | #000 (黑色) | 设置边框的颜色 |
\n
| textAlign | string | 是 | left | 设置文本的对齐方式,可取值:`left`左对齐;`center`居中对齐;`right`右对齐。 |
\n
"
,
"methods"
:{
"beginPath"
:{
"name"
:
"#### beginPath() @beginpath"
,
"description"
:
"
\r\n
创建一个新的空路径"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"arc"
:{
"name"
:
"#### arc(x, y, radius, startAngle, endAngle, anticlockwise?) @arc"
,
"description"
:
"
\r\n
绘制一段弧线"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 圆心的X轴坐标 |
\n
| y | number | 是 | - | 圆心的Y轴坐标 |
\n
| radius | number | 是 | - | 圆弧的半径 |
\n
| startAngle | number | 是 | - | 圆弧的起始点,x 轴方向开始计算,单位为弧度 |
\n
| endAngle | number | 是 | - | 圆弧的终点,单位为弧度 |
\n
| anticlockwise | boolean | 否 | true | 圆弧绘制方向,true:逆时针绘制,false:顺时针绘制。 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"moveTo"
:{
"name"
:
"#### moveTo(x, y) @moveto"
,
"description"
:
"
\r\n
将一个新的路径的起始点移动到 (x,y) 坐标"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 点的X轴坐标 |
\n
| y | number | 是 | - | 点的Y轴坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"rect"
:{
"name"
:
"#### rect(x, y, width, height) @rect"
,
"description"
:
"
\r\n
创建一个矩形路径"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 矩形起点的X轴坐标 |
\n
| y | number | 是 | - | 矩形起点的Y轴坐标 |
\n
| width | number | 是 | - | 矩形宽度 |
\n
| height | number | 是 | - | 矩形高度 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"lineTo"
:{
"name"
:
"#### lineTo(x, y) @lineto"
,
"description"
:
"
\r\n
将路径的最后一个点连接到 (x,y) 坐标"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 线终点的X轴坐标 |
\n
| y | number | 是 | - | 线终点的Y轴坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"closePath"
:{
"name"
:
"#### closePath() @closepath"
,
"description"
:
"
\r\n
闭合路径,将最后一个点与起点连接起来。如果图形已经封闭,或者只有一个点,那么此方法不会产生任何效果。"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"stroke"
:{
"name"
:
"#### stroke() @stroke"
,
"description"
:
"
\r\n
绘制当前或已经存在的路径的边框。"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"strokeRect"
:{
"name"
:
"#### strokeRect(x, y, width, height) @strokerect"
,
"description"
:
"
\r\n
绘制一个矩形框"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 矩形起点的X轴坐标 |
\n
| y | number | 是 | - | 矩形起点的Y轴坐标 |
\n
| width | number | 是 | - | 矩形宽度 |
\n
| height | number | 是 | - | 矩形高度 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"strokeText"
:{
"name"
:
"#### strokeText(text, x, y) @stroketext"
,
"description"
:
"
\r\n
绘制空心字符"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| text | string | 是 | - | 要绘制的字符 |
\n
| x | number | 是 | - | 字符开始绘制的X轴坐标 |
\n
| y | number | 是 | - | 字符开始绘制的Y轴坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"fill"
:{
"name"
:
"#### fill(fillRule?) @fill"
,
"description"
:
"
\r\n
填充当前或已存在的路径"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| fillRule | string | 否 | nonzero | 填充规则。可取值:`nonzero`非零环绕规则;`evenodd`奇偶环绕规则。 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"fillRect"
:{
"name"
:
"#### fillRect(x, y, width, height) @fillrect"
,
"description"
:
"
\r\n
绘制一个实心矩形"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | 矩形起点的X轴坐标 |
\n
| y | number | 是 | - | 矩形起点的Y轴坐标 |
\n
| width | number | 是 | - | 矩形宽度 |
\n
| height | number | 是 | - | 矩形高度 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"fillText"
:{
"name"
:
"#### fillText(text, x, y) @filltext"
,
"description"
:
"
\r\n
绘制实心字符"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| text | string | 是 | - | 要绘制的字符 |
\n
| x | number | 是 | - | 字符开始绘制的X轴坐标 |
\n
| y | number | 是 | - | 字符开始绘制的Y轴坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"reset"
:{
"name"
:
"#### reset() @reset"
,
"description"
:
"
\r\n
清空绘制数据"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"update"
:{
"name"
:
"#### update() @update"
,
"description"
:
"
\r\n
将所有绘制内容更新到画布上"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"setLineDash"
:{
"name"
:
"#### setLineDash(segments) @setlinedash"
,
"description"
:
"
\r\n
设置虚线样式"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| segments | number[
\\
] | 是 | - | 一组描述交替绘制线段和间距长度的数字。 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"bezierCurveTo"
:{
"name"
:
"#### bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) @beziercurveto"
,
"description"
:
"
\r\n
创建三次方贝塞尔曲线路径"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| cp1x | number | 是 | - | 第一个贝塞尔控制点的 x 坐标 |
\n
| cp1y | number | 是 | - | 第一个贝塞尔控制点的 y 坐标 |
\n
| cp2x | number | 是 | - | 第二个贝塞尔控制点的 x 坐标 |
\n
| cp2y | number | 是 | - | 第二个贝塞尔控制点的 y 坐标 |
\n
| x | number | 是 | - | 结束点的 x 坐标 |
\n
| y | number | 是 | - | 结束点的 y 坐标 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}},
"example"
:
"### 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/element-draw/element-draw.uvue)
\n
```vue
\n
<template>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view class=
\"
page-scroll-view
\"
>
\r\n
<!-- #endif -->
\r\n
<view>
\r\n
<view class=
\"
drawing
\"
id=
\"
draw-text-view
\"
></view>
\r\n
<view class=
\"
drawing
\"
id=
\"
draw-line-view
\"
></view>
\r\n
<view class=
\"
drawing
\"
id=
\"
draw-circle-view
\"
></view>
\r\n
<view class=
\"
drawing
\"
id=
\"
draw-dash-line
\"
></view>
\r\n
<view class=
\"
drawing
\"
id=
\"
draw-house
\"
></view>
\r\n
<view class=
\"
drawing
\"
id=
\"
draw-style
\"
></view>
\r\n
<view class=
\"
drawing
\"
id=
\"
draw-odd
\"
></view>
\r\n
<view class=
\"
drawing
\"
id=
\"
draw-arcto
\"
></view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n
<script>
\r\n
var y = 160
\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
texts: [
\r\n
'HBuilderX,轻巧、极速,极客编辑器',
\r\n
'uni-app x,终极跨平台方案',
\r\n
'uniCloud,js serverless云服务',
\r\n
'uts,大一统语言',
\r\n
'uniMPSdk,让你的App具备小程序能力',
\r\n
'uni-admin,开源、现成的全端管理后台',
\r\n
'uni-id,开源、全端的账户中心',
\r\n
'uni-pay,开源、云端一体、全平台的支付',
\r\n
'uni-ai,聚合ai能力',
\r\n
'uni-cms,开源、云端一体、全平台的内容管理平台',
\r\n
'uni-im,开源、云端一体、全平台的im即时消息',
\r\n
'uni统计,开源、完善、全平台的统计报表',
\r\n
'......'
\r\n
] as string[]
\r\n
}
\r\n
},
\r\n
onShow() {
\r\n
},
\r\n\r\n
onReady() {
\r\n
this.drawText()
\r\n
this.drawLines()
\r\n
this.drawCircles()
\r\n
this.drawStar()
\r\n
this.drawhouse()
\r\n
this.drawPoint()
\r\n
this.drawRect()
\r\n
this.drawArcTo()
\r\n
},
\r\n
onUnload() {
\r\n
y = 160
\r\n
},
\r\n
methods: {
\r\n
drawText() {
\r\n
let element = uni.getElementById('draw-text-view')!
\r\n
let ctx = element.getDrawableContext()!
\r\n
let width = element.getBoundingClientRect().width
\r\n
ctx.reset()
\r\n
ctx.font =
\"
15px
\"\r\n
ctx.textAlign =
\"
center
\"\r\n
for (var i = 0; i < this.texts.length; i++) {
\r\n
let value = this.texts[i]
\r\n
if (i % 2 == 0) {
\r\n
ctx.fillText(value, width / 2, (20 * (i + 1)))
\r\n
} else {
\r\n
ctx.strokeText(value, width / 2, (20 * (i + 1)))
\r\n
}
\r\n
}
\r\n
ctx.update()
\r\n
},
\r\n
drawLines() {
\r\n
let ctx = uni.getElementById('draw-line-view')!.getDrawableContext()!
\r\n
ctx.reset()
\r\n
ctx.lineWidth = 10;
\r\n\r\n
[
\"
round
\"
,
\"
bevel
\"
,
\"
miter
\"
].forEach((join, i) => {
\r\n
ctx.lineJoin = join;
\r\n
ctx.beginPath();
\r\n
ctx.moveTo(5, 10 + i * 40);
\r\n
ctx.lineTo(50, 50 + i * 40);
\r\n
ctx.lineTo(90, 10 + i * 40);
\r\n
ctx.lineTo(130, 50 + i * 40);
\r\n
ctx.lineTo(170, 10 + i * 40);
\r\n
ctx.stroke();
\r\n
});
\r\n
ctx.lineWidth = 1
\r\n
var space = 170
\r\n
ctx.strokeStyle = '#09f';
\r\n
ctx.beginPath();
\r\n
ctx.moveTo(10 + space, 10);
\r\n
ctx.lineTo(140 + space, 10);
\r\n
ctx.moveTo(10 + space, 140);
\r\n
ctx.lineTo(140 + space, 140);
\r\n
ctx.stroke();
\r\n
// Draw lines
\r\n
ctx.strokeStyle = 'black';
\r\n
['butt', 'round', 'square'].forEach((lineCap, i) => {
\r\n
ctx.lineWidth = 15;
\r\n
ctx.lineCap = lineCap;
\r\n
ctx.beginPath();
\r\n
ctx.moveTo(25 + space + i * 50, 10);
\r\n
ctx.lineTo(25 + space + i * 50, 140);
\r\n
ctx.stroke();
\r\n
});
\r\n
ctx.lineWidth = 1;
\r\n
this.drawDashedLine([], ctx);
\r\n
this.drawDashedLine([2, 2], ctx);
\r\n
this.drawDashedLine([10, 10], ctx);
\r\n
this.drawDashedLine([20, 5], ctx);
\r\n
this.drawDashedLine([15, 3, 3, 3], ctx);
\r\n
this.drawDashedLine([20, 3, 3, 3, 3, 3, 3, 3], ctx);
\r\n
ctx.lineDashOffset = 18;
\r\n
this.drawDashedLine([12, 3, 3], ctx);
\r\n
ctx.lineDashOffset = 0
\r\n
ctx.setLineDash([0])
\r\n
ctx.update()
\r\n
},
\r\n
drawDashedLine(pattern : Array<number>, ctx : DrawableContext) {
\r\n
ctx.beginPath();
\r\n
ctx.setLineDash(pattern);
\r\n
ctx.moveTo(0, y);
\r\n
ctx.lineTo(300, y);
\r\n
ctx.stroke();
\r\n
y += 15;
\r\n
},
\r\n
drawCircles() {
\r\n
let ctx = uni.getElementById('draw-circle-view')!.getDrawableContext()!
\r\n
ctx.reset()
\r\n
// Draw shapes
\r\n
for (var i = 0; i < 4; i++) {
\r\n
for (var j = 0; j < 3; j++) {
\r\n
ctx.beginPath();
\r\n
var x = 25 + j * 50; // x coordinate
\r\n
var y = 25 + i * 50; // y coordinate
\r\n
var radius = 20; // Arc radius
\r\n
var startAngle = 0; // Starting point on circle
\r\n
var endAngle = Math.PI + (Math.PI * j) / 2; // End point on circle
\r\n
var clockwise = i % 2 == 0 ? false : true; // clockwise or anticlockwise
\r\n\r\n
ctx.arc(x, y, radius, startAngle, endAngle, clockwise);
\r\n\r\n
if (i > 1) {
\r\n
ctx.fill();
\r\n
} else {
\r\n
ctx.stroke();
\r\n
}
\r\n
}
\r\n
}
\r\n
ctx.update()
\r\n
},
\r\n\r\n
drawStar() {
\r\n
let ctx = uni.getElementById('draw-dash-line')!.getDrawableContext()!
\r\n
ctx.reset()
\r\n
ctx.beginPath();
\r\n
var horn = 5; // 画5个角
\r\n
var angle = 360 / horn; // 五个角的度数
\r\n
// 两个圆的半径
\r\n
var R = 50;
\r\n
var r = 20;
\r\n
// 坐标
\r\n
var x = 100;
\r\n
var y = 100;
\r\n
for (var i = 0; i < horn; i++) {
\r\n
// 角度转弧度:角度/180*Math.PI
\r\n
// 外圆顶点坐标
\r\n
ctx.lineTo(Math.cos((18 + i * angle) / 180.0 * Math.PI) * R + x, -Math.sin((18 + i * angle) / 180.0 * Math.PI) * R + y);
\r\n
// 內圆顶点坐标
\r\n
ctx.lineTo(Math.cos((54 + i * angle) / 180.0 * Math.PI) * r + x, -Math.sin((54 + i * angle) / 180.0 * Math.PI) * r + y);
\r\n
}
\r\n
// closePath:关闭路径,将路径的终点与起点相连
\r\n
ctx.closePath();
\r\n
ctx.lineWidth = 3;
\r\n
ctx.fillStyle = '#E4EF00';
\r\n
ctx.strokeStyle =
\"
red
\"
;
\r\n
ctx.fill();
\r\n
ctx.stroke();
\r\n\r\n
ctx.lineWidth = 10;
\r\n
ctx.beginPath()
\r\n
ctx.moveTo(170, 100)
\r\n
ctx.lineTo(255, 15)
\r\n
ctx.lineTo(340, 100)
\r\n
ctx.closePath()
\r\n
ctx.fill()
\r\n
ctx.strokeStyle =
\"
blue
\"\r\n
ctx.stroke()
\r\n
ctx.beginPath()
\r\n
ctx.moveTo(170, 145)
\r\n
ctx.lineTo(255, 45)
\r\n
ctx.lineTo(340, 145)
\r\n
ctx.closePath()
\r\n
ctx.fill()
\r\n
ctx.strokeStyle =
\"
gray
\"\r\n
ctx.stroke()
\r\n
// 未设置beginPath,导致上下表现一致,与前端一致
\r\n
ctx.moveTo(170, 190)
\r\n
ctx.lineTo(255, 90)
\r\n
ctx.lineTo(340, 190)
\r\n
ctx.closePath()
\r\n
ctx.fillStyle =
\"
orange
\"\r\n
ctx.fill()
\r\n
ctx.strokeStyle =
\"
khaki
\"\r\n
ctx.stroke()
\r\n
ctx.update()
\r\n
},
\r\n
hex(num : number) : string {
\r\n
if (num == 0) {
\r\n
return
\"
00
\"\r\n
}
\r\n
let hexChars =
\"
0123456789ABCDEF
\"
;
\r\n
let result =
\"\"
;
\r\n
while (num > 0) {
\r\n
let remainder = Math.floor(num) % 16;
\r\n
result = hexChars[remainder] + result;
\r\n
num = Math.floor(Math.floor(num) / 16);
\r\n
}
\r\n
if (result.length == 1) {
\r\n
return
\"
0
\"
+ result
\r\n
}
\r\n
return result
\r\n
},
\r\n
drawhouse() {
\r\n
let ctx = uni.getElementById('draw-house')!.getDrawableContext()!
\r\n
ctx.reset()
\r\n
ctx.lineWidth = 10;
\r\n\r\n
// Wall
\r\n
ctx.strokeRect(75, 140, 150, 110);
\r\n\r\n
// Door
\r\n
ctx.fillRect(130, 190, 40, 60);
\r\n\r\n
// Roof
\r\n
ctx.beginPath();
\r\n
ctx.moveTo(50, 140);
\r\n
ctx.lineTo(150, 60);
\r\n
ctx.lineTo(250, 140);
\r\n
ctx.closePath();
\r\n
ctx.stroke();
\r\n
ctx.update()
\r\n
},
\r\n
drawPoint() {
\r\n
let ctx = uni.getElementById('draw-style')!.getDrawableContext()!
\r\n
ctx.reset()
\r\n
for (let i = 0; i < 6; i++) {
\r\n
for (let j = 0; j < 6; j++) {
\r\n
ctx.strokeStyle = `rgb(0,${Math.floor(255 - 42.5 * i)},${Math.floor(255 - 42.5 * j)})`;
\r\n
ctx.beginPath();
\r\n
ctx.arc(12.5 + j * 25, 12.5 + i * 25, 10, 0, Math.PI * 2, true);
\r\n
ctx.stroke();
\r\n
}
\r\n
}
\r\n
for (let i = 0; i < 6; i++) {
\r\n
for (let j = 0; j < 6; j++) {
\r\n
ctx.fillStyle = `rgb(${Math.floor(255 - 42.5 * i)},${Math.floor(255 - 42.5 * j)},0)`;
\r\n
ctx.fillRect(180 + j * 25, i * 25, 25, 25);
\r\n
}
\r\n
}
\r\n
ctx.update()
\r\n
},
\r\n
drawRect() {
\r\n
let ctx = uni.getElementById('draw-odd')!.getDrawableContext()!
\r\n
ctx.reset()
\r\n
// Create path
\r\n
ctx.moveTo(30, 90);
\r\n
ctx.lineTo(110, 20);
\r\n
ctx.lineTo(240, 130);
\r\n
ctx.lineTo(60, 130);
\r\n
ctx.lineTo(190, 20);
\r\n
ctx.lineTo(270, 90);
\r\n
ctx.closePath();
\r\n\r\n
// Fill path
\r\n
ctx.fillStyle =
\"
green
\"
;
\r\n
ctx.fill(
\"
evenodd
\"
);
\r\n
ctx.update()
\r\n\r\n
},
\r\n
drawArcTo() {
\r\n
let ctx = uni.getElementById('draw-arcto')!.getDrawableContext()!
\r\n
ctx.reset()
\r\n
ctx.beginPath();
\r\n
ctx.moveTo(50, 20);
\r\n
ctx.bezierCurveTo(230, 30, 150, 60, 50, 100);
\r\n
ctx.stroke();
\r\n\r\n
ctx.fillStyle =
\"
blue
\"
;
\r\n
// start point
\r\n
ctx.fillRect(50, 20, 10, 10);
\r\n
// end point
\r\n
ctx.fillRect(50, 100, 10, 10);
\r\n\r\n
ctx.fillStyle =
\"
red
\"
;
\r\n
// control point one
\r\n
ctx.fillRect(230, 30, 10, 10);
\r\n
// control point two
\r\n
ctx.fillRect(150, 70, 10, 10);
\r\n
ctx.update()
\r\n
}
\r\n
}
\r\n
}
\r\n
</script>
\r\n\r\n
<style>
\r\n
.drawing {
\r\n
height: 275px;
\r\n
background-color: lightgray;
\r\n
margin-bottom: 15px;
\r\n
}
\r\n
</style>
\r\n\n
```"
},
"UniCallbackWrapper"
:{
"name"
:
"## UniCallbackWrapper"
,
"description"
:
"
\r\n
事件回调封装类,用于注销监听函数的形参"
,
"extends"
:
""
,
"param"
:
""
},
"UniEvent"
:{
"name"
:
"## UniEvent"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| eventInit | [UTSJSONObject](/uts/buildin-object-api/utsjsonobject.md) | 是 | - | - |
\n\n
### UniEvent 的属性值 @unievent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\r\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\r\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"CustomEvent"
:{
"name"
:
"## CustomEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- CustomEvent : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| options | any | 是 | - | - |
\n\n
### CustomEvent 的属性值 @customevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| detail | T | 是 | - | - |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\r\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\r\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"MouseEvent"
:{
"name"
:
"## MouseEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniPointerEvent : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| x | number | 是 | - | - |
\n
| y | number | 是 | - | - |
\n
| clientX | number | 是 | - | - |
\n
| clientY | number | 是 | - | - |
\n
| pageX | number | 是 | - | - |
\n
| pageY | number | 是 | - | - |
\n
| screenX | number | 是 | - | - |
\n
| screenY | number | 是 | - | - |
\n\n
### MouseEvent 的属性值 @mouseevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| clientX | number | 是 | - | 相对于页面可显示区域左边的距离 |
\n
| clientY | number | 是 | - | 相对于页面可显示区域顶部的距离 |
\n
| x | number | 是 | - | 相对于页面可显示区域左边的距离,同`clientX` |
\n
| y | number | 是 | - | 相对于页面可显示区域顶部的距离,同`clientY` |
\n
| pageX | number | 是 | - | 相对于文档左边的距离 |
\n
| pageY | number | 是 | - | 相对于文档顶部的距离 |
\n
| screenX | number | 是 | - | 相对于屏幕左边距离 |
\n
| screenY | number | 是 | - | 相对于屏幕顶部的距离 |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\r\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\r\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"TouchEvent"
:{
"name"
:
"## TouchEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniTouchEvent : Extend
\n
```"
,
"param"
:
"
\n
### TouchEvent 的属性值 @touchevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| touches | Array
\\
<[UniTouch](#unitouch-values)
\\
> | 是 | - | 当前停留在屏幕中的触摸点信息的数组 |
\n
| changedTouches | Array
\\
<[UniTouch](#unitouch-values)
\\
> | 是 | - | 当前变化的触摸点信息的数组 |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\r\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\r\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UniTouch"
:{
"name"
:
"## UniTouch"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### UniTouch 的属性值 @unitouch-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| clientX | number | 是 | - | 相对于页面可显示区域左边的距离 |
\n
| clientY | number | 是 | - | 相对于页面可显示区域顶部的距离 |
\n
| identifier | number | 是 | - | 触摸点的标识符。这个值在这根手指所引发的所有事件中保持一致,直到手指抬起。 |
\n
| pageX | number | 是 | - | 相对于文档左边的距离 |
\n
| pageY | number | 是 | - | 相对于文档顶部的距离 |
\n
| screenX | number | 是 | - | 相对于屏幕左边距离 |
\n
| screenY | number | 是 | - | 相对于屏幕顶部的距离 |
\n
| force | number | 否 | - | 返回当前触摸点按下的压力大小 |
\n
"
},
"Touch"
:{
"name"
:
"## Touch"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### Touch 的属性值 @touch-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| clientX | number | 是 | - | 相对于页面可显示区域左边的距离 |
\n
| clientY | number | 是 | - | 相对于页面可显示区域顶部的距离 |
\n
| identifier | number | 是 | - | 触摸点的标识符。这个值在这根手指所引发的所有事件中保持一致,直到手指抬起。 |
\n
| pageX | number | 是 | - | 相对于文档左边的距离 |
\n
| pageY | number | 是 | - | 相对于文档顶部的距离 |
\n
| screenX | number | 是 | - | 相对于屏幕左边距离 |
\n
| screenY | number | 是 | - | 相对于屏幕顶部的距离 |
\n
| force | number | 否 | - | 返回当前触摸点按下的压力大小 |
\n
"
},
"UniCustomEvent"
:{
"name"
:
"## UniCustomEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniCustomEvent : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| options | any | 是 | - | - |
\n\n
### UniCustomEvent 的属性值 @unicustomevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| detail | T | 是 | - | - |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\r\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\r\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UniMouseEvent"
:{
"name"
:
"## UniMouseEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniPointerEvent : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | - |
\n
| x | number | 是 | - | - |
\n
| y | number | 是 | - | - |
\n
| clientX | number | 是 | - | - |
\n
| clientY | number | 是 | - | - |
\n
| pageX | number | 是 | - | - |
\n
| pageY | number | 是 | - | - |
\n
| screenX | number | 是 | - | - |
\n
| screenY | number | 是 | - | - |
\n\n
### UniMouseEvent 的属性值 @unimouseevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| clientX | number | 是 | - | 相对于页面可显示区域左边的距离 |
\n
| clientY | number | 是 | - | 相对于页面可显示区域顶部的距离 |
\n
| x | number | 是 | - | 相对于页面可显示区域左边的距离,同`clientX` |
\n
| y | number | 是 | - | 相对于页面可显示区域顶部的距离,同`clientY` |
\n
| pageX | number | 是 | - | 相对于文档左边的距离 |
\n
| pageY | number | 是 | - | 相对于文档顶部的距离 |
\n
| screenX | number | 是 | - | 相对于屏幕左边距离 |
\n
| screenY | number | 是 | - | 相对于屏幕顶部的距离 |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\r\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\r\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UniTouchEvent"
:{
"name"
:
"## UniTouchEvent"
,
"description"
:
""
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
UniEvent <|-- UniTouchEvent : Extend
\n
```"
,
"param"
:
"
\n
### UniTouchEvent 的属性值 @unitouchevent-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| touches | Array
\\
<[UniTouch](#unitouch-values)
\\
> | 是 | - | 当前停留在屏幕中的触摸点信息的数组 |
\n
| changedTouches | Array
\\
<[UniTouch](#unitouch-values)
\\
> | 是 | - | 当前变化的触摸点信息的数组 |
\n
| type | string | 是 | - | 事件类型 |
\n
| target | [UniElement](/dom/unielement.md) | 否 | - | 触发事件的组件 |
\n
| currentTarget | [UniElement](/dom/unielement.md) | 否 | - | 当前组件 |
\n
| timeStamp | number | 是 | - | 事件发生时的时间戳 |
\n
"
,
"methods"
:{
"stopPropagation"
:{
"name"
:
"#### stopPropagation() @stoppropagation"
,
"description"
:
"
\r\n
阻止当前事件的进一步传播"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"preventDefault"
:{
"name"
:
"#### preventDefault() @preventdefault"
,
"description"
:
"
\r\n
阻止当前事件的默认行为"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"Element"
:{
"name"
:
"## Element"
,
"description"
:
""
,
"extends"
:
""
,
"param"
:
"
\n
### Element 的属性值 @element-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| classList | Array
\\
<string
\\
> | 是 | - | 只读属性 获取当前元素的的 class 属性的动态集合。 |
\n
| firstChild | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的的第一个子元素,如果元素是无子元素,则返回 null。 |
\n
| lastChild | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的最后一个子元素,如果没有子元素,则返回 null。 |
\n
| parentElement | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素在 DOM 树中的父元素,如果没有父元素(如未添加到DOM树中),则返回null。 |
\n
| previousSibling | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取当前元素的前一个同级元素,没有则返回null。 |
\n
| nextElementSibling | [UniElement](/dom/unielement.md) | 否 | - | 只读属性 获取在 DOM 树中紧跟在其后面的同级元素,如果指定的元素为最后一个元素,则返回 null。 |
\n
| children | Array
\\
<[UniElement](/dom/unielement.md)
\\
> | 是 | - | 只读属性 获取当前元素包含的子元素的集合 |
\n
| tagName | string | 是 | - | 只读属性 获取当前元素的标签名 |
\n
| dataset | Map
\\
<string, any> | 是 | - | 只读属性 获取元素上自定义数据属性(data-*)的集合 |
\n
| attributes | Map
\\
<string, any> | 是 | - | 只读属性 获取元素上所有属性元素的集合 |
\n
| style | [CSSStyleDeclaration](/dom/cssstyledeclaration.md) | 是 | - | 只读属性 获取元素的CSS样式对象 |
\n
| scrollWidth | number | 是 | - | 只读属性 获取可滚动元素内容的总宽度,仅scroll-view、list-view组件支持,其他组件返回视图宽度 |
\n
| scrollHeight | number | 是 | - | 只读属性 获取可滚动元素内容的总高度,仅scroll-view、list-view组件支持,其他组件返回视图高度 |
\n
| scrollLeft | number | 是 | - | 获取或修改元素滚动条到元素左边的距离像素数,仅scroll-view、list-view组件支持。其他组件返回0 |
\n
| scrollTop | number | 是 | - | 获取或修改元素滚动条到元素顶部的距离像素数,仅scroll-view、list-view组件支持。其他组件返回0 |
\n
| offsetLeft | number | 是 | - | 只读属性 元素的左边界偏移值 单位px |
\n
| offsetTop | number | 是 | - | 只读属性 元素的顶部边界偏移值 单位px |
\n
| offsetWidth | number | 是 | - | 只读属性 元素的布局宽度,宽度包含border、padding的数据值 单位px |
\n
| offsetHeight | number | 是 | - | 只读属性 元素的布局高度,高度包含border、padding的数据值 单位px |
\n
| ext | Map
\\
<string, any> | 是 | - | 只读属性 扩展属性 |
\n
"
,
"methods"
:{
"takeSnapshot"
:{
"name"
:
"#### takeSnapshot(options) @takesnapshot"
,
"description"
:
"
\r\n
对当前组件进行截图,调用此方法会将当前组件(包含子节点)渲染结果导出成图片。
\r\n
成功会返回图片对应的临时文件路径,目前默认png格式
\r\n
"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [TakeSnapshotOptions](#takesnapshotoptions-values) | 是 | - | 组件截图的参数对象 |
\n
###### TakeSnapshotOptions 的属性值 @takesnapshotoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 否 |
\"
file
\"
| 截图导出类型,目前仅支持 'file' 保存到临时文件目录 |
\n
| format | string | 否 |
\"
png
\"
| 截图文件格式,目前仅支持 'png' |
\n
| success | (res: [TakeSnapshotSuccess](#takesnapshotsuccess-values)) => void | 否 | - | 接口调用成功的回调函数 |
\n
| fail | (res: [TakeSnapshotFail](#takesnapshotfail-values)) => void | 否 | - | 接口调用失败的回调函数 |
\n
| complete | (res: any) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |
\n\n
###### TakeSnapshotSuccess 的属性值 @takesnapshotsuccess-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFilePath | string | 是 | - | 截图保存的临时文件路径 |
\n\n
###### TakeSnapshotFail 的属性值 @takesnapshotfail-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errMsg | string | 是 | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"##### takeSnapshot 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.93 | x | x |
\n
"
,
"tutorial"
:
""
},
"appendChild"
:{
"name"
:
"#### appendChild(aChild) @appendchild"
,
"description"
:
"
\r\n
将一个元素添加到指定父元素的子元素列表的末尾处。如果将被插入的元素已经存在于当前文档的文档树中,那么将会它从原先的位置移动到新的位置。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| aChild | [UniElement](/dom/unielement.md) | 是 | - | 插入子元素对象 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"insertBefore"
:{
"name"
:
"#### insertBefore(newChild, refChild?) @insertbefore"
,
"description"
:
"
\r\n
在参考元素之前插入一个拥有指定父元素的子元素。如果给定的子元素是对文档中现有元素的引用,insertBefore() 会将其从当前位置移动到新位置。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| newChild | [UniElement](/dom/unielement.md) | 是 | - | 插入子元素对象 |
\n
| refChild | [UniElement](/dom/unielement.md) | 否 | - | 已存在父元素的子元素对象 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"setAttribute"
:{
"name"
:
"#### setAttribute(key, value) @setattribute"
,
"description"
:
"
\r\n
设置指定元素上的某个属性值。如果设置的属性已经存在,则更新该属性值;否则使用指定的名称和值添加一个新的属性。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |
\n
| value | string | 是 | - | 属性值域 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getAttribute"
:{
"name"
:
"#### getAttribute(key) @getattribute"
,
"description"
:
"
\r\n
获取元素指定的属性值,如果指定的属性不存在则返回null。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| string | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"hasAttribute"
:{
"name"
:
"#### hasAttribute(key) @hasattribute"
,
"description"
:
"
\r\n
返回改元素是否包含有指定的属性,属性存在则返回true,否则返回false。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| boolean |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeAttribute"
:{
"name"
:
"#### removeAttribute(key) @removeattribute"
,
"description"
:
"
\r\n
从元素中删除一个属性,如果指定的属性不存在,则不做任何操作,也不会产生错误。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| key | string | 是 | - | 属性名称 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getBoundingClientRect"
:{
"name"
:
"#### getBoundingClientRect() @getboundingclientrect"
,
"description"
:
"
\r\n
获取元素的大小及其相对于窗口的位置信息。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [DOMRect](/dom/domrect.md) |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"getDrawableContext"
:{
"name"
:
"#### getDrawableContext() @getdrawablecontext"
,
"description"
:
"
\r\n
获取组件的绘制对象,仅uvue页面中的 view 组件支持,其它组件不支持则返回null。"
,
"param"
:
""
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [DrawableContext](/dom/drawablecontext.md) | 否 |
\n
"
,
"compatibility"
:
"##### getDrawableContext 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.9 | x | x |
\n
"
,
"tutorial"
:
""
},
"addEventListener"
:{
"name"
:
"#### addEventListener(type, callback) @addeventlistener"
,
"description"
:
"
\r\n
将指定的监听器注册到元素对象上,当该对象触发指定的事件时,指定的回调函数就会被执行。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| callback | (event: T) => R | 是 | - | 事件监听器 T表示event类型,R表示返回值类型 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| UniCallbackWrapper |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeEventListener"
:{
"name"
:
"#### removeEventListener(type, callbackWrapper) @removeeventlistener"
,
"description"
:
"
\r\n
删除使用 addEventListener 方法添加的事件监听器。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| callbackWrapper | UniCallbackWrapper | 是 | - | 事件监听回调封装类 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"removeChild"
:{
"name"
:
"#### removeChild(aChild) @removechild"
,
"description"
:
"
\r\n
从元素中删除一个子元素,返回删除的元素。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| aChild | [UniElement](/dom/unielement.md) | 是 | - | 被删除子元素对象 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"remove"
:{
"name"
:
"#### remove() @remove"
,
"description"
:
"
\r\n
把元素对象从它所属的 DOM 树中删除。"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"dispatchEvent"
:{
"name"
:
"#### dispatchEvent(type, value) @dispatchevent"
,
"description"
:
"
\r\n
向一个指定的事件目标派发一个 Event,并以合适的顺序(同步地)调用此事件的监听器回调函数。"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 事件类型 |
\n
| value | [UniEvent](/component/common#unievent) | 是 | - | 事件返回对象 |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"scrollTo"
:{
"name"
:
"#### scrollTo(x, y) @scrollto"
,
"description"
:
"
\r\n
使界面滚动到给定元素的指定坐标位置 仅scroll-view、list-view组件支持"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | x轴要滚动到坐标位置(单位px) |
\n
| y | number | 是 | - | y轴要滚动到坐标位置(单位px) |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"scrollBy"
:{
"name"
:
"#### scrollBy(x, y) @scrollby"
,
"description"
:
"
\r\n
使得元素滚动一段特定距离 仅scroll-view、list-view组件支持"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| x | number | 是 | - | x轴要滚动的距离(单位px) |
\n
| y | number | 是 | - | y轴要滚动的距离(单位px) |"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"querySelector"
:{
"name"
:
"#### querySelector(selector) @queryselector"
,
"description"
:
"
\r\n
返回文档中与指定选择器或选择器组匹配的第一个 Element对象。如果找不到匹配项,则返回null"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| selector | string.cssSelectorString | 是 | - | CSS 选择器字符串 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| [UniElement](/dom/unielement.md) | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"querySelectorAll"
:{
"name"
:
"#### querySelectorAll(selector) @queryselectorall"
,
"description"
:
"
\r\n
返回与指定的选择器组匹配的文档中的元素列表"
,
"param"
:
"##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| selector | string.cssSelectorString | 是 | - | CSS 选择器字符串 |"
,
"returnValue"
:
"##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| Array
\\
<[UniElement](/dom/unielement.md)
\\
> | 否 |
\n
"
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"focus"
:{
"name"
:
"#### focus() @focus"
,
"description"
:
"
\r\n
使元素获取焦点 仅input、Textarea组件支持"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"blur"
:{
"name"
:
"#### blur() @blur"
,
"description"
:
"
\r\n
使元素丢失焦点 仅input、Textarea组件支持"
,
"param"
:
""
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
}}},
"UniError"
:{
"name"
:
"## UniError"
,
"description"
:
"
\r\n
uni api统一错误信息对象 "
,
"extends"
:
"```mermaid
\n
classDiagram
\n\n
Error <|-- UniError : Extend
\n
```"
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errSubject | string | 是 | - | - |
\n
| errCode | number | 是 | - | - |
\n
| errMsg | string | 是 | - | - |
\n\n
### UniError 的属性值 @unierror-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| errSubject | string | 是 | - | 统一错误主题(模块)名称 |
\n
| errCode | number | 是 | - | 统一错误码 |
\n
| errMsg | string | 是 | - | 统一错误描述信息 |
\n
| data | any | 否 | - | 错误信息中包含的数据 |
\n
| cause | [Error](https://uniapp.dcloud.net.cn/tutorial/err-spec.html#unierror) | 否 | - | 源错误信息,可以包含多个错误,详见SourceError |
\n
| name | string | 是 | - | - |
\n
| message | string | 是 | - | - |
\n
"
},
"Error"
:{
"name"
:
"## Error"
,
"description"
:
"
\r\n
UTS错误信息对象"
,
"extends"
:
""
,
"param"
:
"
\n
### 构造函数
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| message | string | 是 | - | - |
\n
| options | [UTSJSONObject](/uts/buildin-object-api/utsjsonobject.md) | 是 | - | - |
\n\n
### Error 的属性值 @error-values
\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string | 是 | - | - |
\n
| message | string | 是 | - | - |
\n
| cause | [Error](https://uniapp.dcloud.net.cn/tutorial/err-spec.html#unierror) | 否 | - | - |
\n
"
},
"general-attribute"
:{
"example"
:
"### 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/component/general-attribute/general-attribute.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/component/general-attribute/general-attribute
\n
>Template
\n
```vue
\n
<template>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view style=
\"
flex: 1
\"
>
\r\n
<!-- #endif -->
\r\n
<view>
\r\n
<page-head :title=
\"
title
\"
></page-head>
\r\n
<view class=
\"
uni-padding-wrap container
\"
>
\r\n
<view
\r\n
:id=
\"
generalId
\"\r\n
:class=
\"
generalClass
\"\r\n
:name=
\"
generalName
\"\r\n
:title=
\"
generalTitle
\"\r\n
:data-test=
\"
generalData
\"\r\n
:style=
\"
generalStyle
\"\r\n
ref=
\"
general-target
\"\r\n
>
\r\n
<text>id: {{ generalId }}</text>
\r\n
<text>class: {{ generalClass }}</text>
\r\n
<text>name: {{ generalName }}</text>
\r\n
<text>title: {{ generalTitle }}</text>
\r\n
<text>data-test: {{ generalData }}</text>
\r\n
<text>style: {{ generalStyle }}</text>
\r\n
</view>
\r\n
<view
\r\n
class=
\"
btn btn-style uni-common-mt
\"\r\n
@click=
\"
validateGeneralAttributes
\"\r\n
>
\r\n
<text class=
\"
btn-inner
\"
>{{ validateGeneralAttrText }}</text>
\r\n
</view>
\r\n
<view class=
\"
btn btn-ref uni-common-mt
\"
@click=
\"
changeHeight
\"
>
\r\n
<text class=
\"
btn-inner
\"
>{{changeHeightByRefText}}</text>
\r\n
</view>
\r\n
<view class=
\"
view-class
\"
:hover-class=
\"
hoverClass
\"
ref=
\"
view-target
\"
>
\r\n
<text class=
\"
text
\"
>按下 50 ms 后背景变红</text>
\r\n
<text class=
\"
text
\"
>抬起 400 ms 后背景恢复</text>
\r\n
</view>
\r\n
<view
\r\n
class=
\"
view-class
\"\r\n
:hover-class=
\"
hoverClass
\"\r\n
:hover-start-time=
\"
1000
\"\r\n
:hover-stay-time=
\"
1000
\"\r\n
ref=
\"
view-target
\"\r\n
>
\r\n
<text class=
\"
text
\"
>按下 1000 ms 后背景变红</text>
\r\n
<text class=
\"
text
\"
>抬起 1000 ms 后背景恢复</text>
\r\n
</view>
\r\n
</view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n\r\n\r\n
<style>
\r\n
.btn {
\r\n
height: 50px;
\r\n
display: flex;
\r\n
align-items: center;
\r\n
justify-content: center;
\r\n
background-color: #409eff;
\r\n
border-radius: 5px;
\r\n
}
\r\n
.btn-inner {
\r\n
color: #fff;
\r\n
}
\r\n
.general-class {
\r\n
margin-left: 40px;
\r\n
padding: 10px;
\r\n
width: 260px;
\r\n
height: 160px;
\r\n
background-color: antiquewhite;
\r\n
}
\r\n
.view-class {
\r\n
margin: 20px 0 0 50px;
\r\n
padding: 10px;
\r\n
width: 240px;
\r\n
height: 100px;
\r\n
background-color: antiquewhite;
\r\n
}
\r\n
.view-class .text {
\r\n
margin-top: 5px;
\r\n
text-align: center;
\r\n
}
\r\n
.hover-class {
\r\n
background-color: red;
\r\n
}
\r\n
</style>
\r\n\n
```
\n
>Script
\n
```uts
\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
title: 'general-attribute',
\r\n
generalId: 'general-id',
\r\n
generalClass: 'general-class',
\r\n
generalName: 'general-name',
\r\n
generalTitle: 'general-title',
\r\n
generalData: 'general-data',
\r\n
generalStyle: 'background-color: aqua',
\r\n
validateGeneralAttrText: '验证基础属性',
\r\n
hoverClass: 'hover-class',
\r\n
validateViewAttrText: '验证 view 属性',
\r\n
changeHeightByRefText: '通过 ref 修改高度',
\r\n
}
\r\n
},
\r\n
methods: {
\r\n
validateGeneralAttributes() {
\r\n
const generalTarget = this.$refs['general-target'] as UniElement
\r\n
const generalId = generalTarget.getAttribute('id')
\r\n
if (generalId != this.generalId) {
\r\n
this.validateGeneralAttrText = '基础属性 id 验证失败'
\r\n
return
\r\n
}
\r\n
// #ifdef APP
\r\n
if (!generalTarget.classList.includes('general-class')) {
\r\n
// #endif
\r\n
// #ifdef WEB
\r\n
if (!Array.from(generalTarget.classList).includes('general-class')) {
\r\n
// #endif
\r\n
this.validateGeneralAttrText = '基础属性 class 验证失败'
\r\n
return
\r\n
}
\r\n
const generalName = generalTarget.getAttribute('name')
\r\n
if (generalName != this.generalName) {
\r\n
this.validateGeneralAttrText = '基础属性 name 验证失败'
\r\n
return
\r\n
}
\r\n
const generalTitle = generalTarget.getAttribute('title')
\r\n
if (generalTitle != this.generalTitle) {
\r\n
this.validateGeneralAttrText = '基础属性 title 验证失败'
\r\n
return
\r\n
}
\r\n
const generalData = generalTarget.getAttribute('data-test')
\r\n
if (generalData != this.generalData) {
\r\n
this.validateGeneralAttrText = '基础属性 data-test 验证失败'
\r\n
return
\r\n
}
\r\n
this.validateGeneralAttrText = '基础属性验证成功'
\r\n
},
\r\n
changeHeight(){
\r\n
const generalTarget = this.$refs['general-target'] as UniElement
\r\n
this.changeHeightByRefText = '已通过 ref 修改高度'
\r\n
generalTarget.style.setProperty('height', '200px')
\r\n
}
\r\n
},
\r\n
}
\r\n\n
```
\n\n
:::"
},
"general-event"
:{
"example"
:
"### 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/component/general-event/general-event.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/component/general-event/general-event
\n
>Template
\n
```vue
\n
<template>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view style=
\"
flex: 1
\"
>
\r\n
<!-- #endif -->
\r\n
<page-head title=
\"
触摸方块测试相关事件
\"
></page-head>
\r\n
<view class=
\"
uni-padding-wrap uni-common-mt container
\"
>
\r\n
<view class=
\"
target
\"
@touchstart=
\"
onTouchStart
\"
@touchcancel=
\"
onTouchCancel
\"
@touchmove=
\"
onTouchMove
\"\r\n
@touchend=
\"
onTouchEnd
\"
@tap=
\"
onTap
\"
@click=
\"
onClick
\"
@longpress=
\"
onLongPress
\"
></view>
\r\n
<view v-if=
\"
touchStartEvent !== null
\"
>
\r\n
<text class=
\"
title1
\"
>touchStart Event: </text>
\r\n
<text class=
\"
title2
\"
>touches: </text>
\r\n
<template v-for=
\"
(touch, index) in touchStartEvent!.touches
\"
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\r\n
<template v-for=
\"
(touch, index) in touchStartEvent!.changedTouches
\"
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
</view>
\r\n
<view v-if=
\"
touchCancelEvent !== null
\"
>
\r\n
<text class=
\"
title1
\"
>touchCancel Event: </text>
\r\n
<text class=
\"
title2
\"
>touches: </text>
\r\n
<template v-for=
\"
(touch, index) in touchCancelEvent!.touches
\"
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\r\n
<template v-for=
\"
(touch, index) in touchCancelEvent!.changedTouches
\"
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
</view>
\r\n
<view v-if=
\"
touchMoveEvent !== null
\"
>
\r\n
<text class=
\"
title1
\"
>touchMove Event: </text>
\r\n
<text class=
\"
title2
\"
>touches: </text>
\r\n
<template v-for=
\"
(touch, index) in touchMoveEvent!.touches
\"
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\r\n
<template v-for=
\"
(touch, index) in touchMoveEvent!.changedTouches
\"
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
</view>
\r\n
<view v-if=
\"
longPressEvent !== null
\"
>
\r\n
<text class=
\"
title1
\"
>longPress Event: </text>
\r\n
<text class=
\"
title2
\"
>touches: </text>
\r\n
<template v-if=
\"
longPressEvent!.touches.length > 0
\"
v-for=
\"
(touch, index) in longPressEvent!.touches
\"\r\n
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\r\n
<template v-for=
\"
(touch, index) in longPressEvent!.changedTouches
\"
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
</view>
\r\n
<view v-if=
\"
touchEndEvent !== null
\"
>
\r\n
<text class=
\"
title1
\"
>touchEnd Event: </text>
\r\n
<text class=
\"
title2
\"
>touches: </text>
\r\n
<template v-if=
\"
touchEndEvent!.touches.length > 0
\"
v-for=
\"
(touch, index) in touchEndEvent!.touches
\"\r\n
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
<text class=
\"
title2 uni-common-mt
\"
>changedTouches: </text>
\r\n
<template v-for=
\"
(touch, index) in touchEndEvent!.changedTouches
\"
:key=
\"
index
\"
>
\r\n
<text class=
\"
title3
\"
>touch[{{ index }}]:</text>
\r\n
<text>identifier: {{touch.identifier}}</text>
\r\n
<text>pageX: {{ touch.pageX }}, pageY: {{ touch.pageY }}</text>
\r\n
<text>clientX: {{ touch.clientX }}, clientY: {{ touch.clientY }}</text>
\r\n
<text>screenX: {{ touch.screenX }}, screenY: {{ touch.screenY }}</text>
\r\n
</template>
\r\n
</view>
\r\n
<view v-if=
\"
tapEvent !== null
\"
>
\r\n
<text class=
\"
title1
\"
>tap Event: </text>
\r\n
<text>x: {{ tapEvent!.x }}, y: {{ tapEvent!.y }}</text>
\r\n
</view>
\r\n
<view v-if=
\"
clickEvent !== null
\"
>
\r\n
<text class=
\"
title1
\"
>click Event: </text>
\r\n
<text>x: {{ clickEvent!.x }}, y: {{ clickEvent!.y }}</text>
\r\n
</view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n\r\n
<style>
\r\n
.container {
\r\n
padding-bottom: 10px;
\r\n
}
\r\n\r\n
.target {
\r\n
margin: 20px 0 0 50px;
\r\n
width: 200px;
\r\n
height: 100px;
\r\n
background-color: aqua;
\r\n
}
\r\n\r\n
.title1 {
\r\n
margin-top: 15px;
\r\n
font-size: 20px;
\r\n
}
\r\n\r\n
.title2 {
\r\n
margin-top: 10px;
\r\n
font-size: 18px;
\r\n
}
\r\n\r\n
.title3 {
\r\n
margin-top: 5px;
\r\n
font-size: 16px;
\r\n
}
\r\n
</style>
\r\n\n
```
\n
>Script
\n
```uts
\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
title: 'general-event',
\r\n
onTouchStartTime: 0,
\r\n
touchStartEvent: null as TouchEvent | null,
\r\n
touchCancelEvent: null as TouchEvent | null,
\r\n
onTouchMoveTime: 0,
\r\n
touchMoveEvent: null as TouchEvent | null,
\r\n
onTouchEndTime: 0,
\r\n
longPressEvent: null as TouchEvent | null,
\r\n
touchEndEvent: null as TouchEvent | null,
\r\n
onTapTime: 0,
\r\n
tapEvent: null as PointerEvent | null,
\r\n
onClickTime: 0,
\r\n
clickEvent: null as PointerEvent | null,
\r\n
onLongPressTime: 0,
\r\n
}
\r\n
},
\r\n
methods: {
\r\n
onTouchStart(e : TouchEvent) {
\r\n
this.touchStartEvent = e
\r\n
this.onTouchStartTime = Date.now()
\r\n
console.log('onTouchStart')
\r\n
},
\r\n
onTouchCancel(e : TouchEvent) {
\r\n
this.touchCancelEvent = e
\r\n
console.log('onTouchCancel')
\r\n
},
\r\n
onTouchMove(e : TouchEvent) {
\r\n
this.touchMoveEvent = e
\r\n
this.onTouchMoveTime = Date.now()
\r\n
console.log('onTouchMove')
\r\n
},
\r\n
onLongPress(e : TouchEvent) {
\r\n
this.longPressEvent = e
\r\n
this.onLongPressTime = Date.now()
\r\n
console.log('onLongPress')
\r\n
},
\r\n
onTouchEnd(e : TouchEvent) {
\r\n
this.touchEndEvent = e
\r\n
this.onTouchEndTime = Date.now()
\r\n
console.log('onTouchEnd')
\r\n
},
\r\n
onTap(e : PointerEvent) {
\r\n
this.tapEvent = e
\r\n
this.onTapTime = Date.now()
\r\n
console.log('onTap')
\r\n
},
\r\n
onClick(e : PointerEvent) {
\r\n
this.clickEvent = e
\r\n
this.onClickTime = Date.now()
\r\n
console.log('onClick')
\r\n
},
\r\n
},
\r\n
}
\r\n\n
```
\n\n
:::"
}}
\ No newline at end of file
docs/.vuepress/utils/pagesJson.json
浏览文件 @
f99a1eeb
{
"pages"
:{
"compatibility"
:
"**pages.json 兼容性**
\n
| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| globalStyle | 5.0 | √ | x | 4.0 |
\n
| pages | 5.0 | √ | x | 4.0 |
\n
| tabBar | 5.0 | √ | x | 4.0 |
\n
| condition | 5.0 | √ | x | 4.0 |
\n
| easycom | 5.0 | √ | x | 4.0 |
\n
| uniIdRouter | 5.0 | 3.99 | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| globalStyle | [globalStyle 配置项列表](#pages-globalstyle) | - | 否 | - |
\n
| pages | Array
\\
<[PagesOptionsPage](#pagesoptionspage)> | - | 是 | 页面路径及窗口表现 |
\n
| tabBar | [tabBar 配置项列表](#pages-tabbar) | - | 否 | - |
\n
| condition | [condition 配置项列表](#pages-condition) | - | 否 | - |
\n
| easycom | [easycom 配置项列表](#pages-easycom) | - | 否 | 组件自动引入规则 |
\n
| uniIdRouter | [uniIdRouter 配置项列表](#pages-uniidrouter) | - | 否 | 根据用户登录状态、页面是否要求登录、以及接口返回的用户token验证状态自动跳转登录页面。详细教程:[详见](https://doc.dcloud.net.cn/uniCloud/uni-id/summary.html#uni-id-router) |"
},
"pages_globalStyle"
:{
"compatibility"
:
"**globalStyle 兼容性**
\n
| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| navigationBarBackgroundColor | 5.0 | √ | x | 4.0 |
\n
| navigationBarTextStyle | 5.0 | √ | x | 4.0 |
\n
| navigationBarTitleText | 5.0 | √ | x | 4.0 |
\n
| navigationStyle | 5.0 | √ | x | 4.0 |
\n
| backgroundColor | 5.0 | 3.99 | x | 4.0 |
\n
| backgroundColorContent | 5.0 | 4.0 | x | x |
\n
| enablePullDownRefresh | 5.0 | √ | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| navigationBarBackgroundColor | string (string.ColorString) | `app`: #F8F8F8<br/>`web`: #F8F8F8<br/>`mp-weixin、mp-qq、mp-baidu、mp-toutiao、mp-lark、mp-jd`: #000000<br/>`mp-alipay、mp-kuaishou`: #ffffff | 否 | 导航栏背景颜色(同状态栏背景色) |
\n
| navigationBarTextStyle | 'white'
\\
| 'black' |
\"
black
\"
| 否 | 导航栏标题颜色,仅支持 black/white(支付宝小程序不支持,请使用 [my.setNavigationBar](https://opendocs.alipay.com/mini/api/xwq8e6))。 |
\n
| navigationBarTitleText | string | - | 否 | 导航栏标题文字内容 |
\n
| navigationStyle | 'defaultValue'
\\
| 'custom' |
\"
defaultValue
\"
| 否 | 导航栏样式,仅支持 default/custom。custom即取消默认的原生导航栏,需看[使用注意](https://uniapp.dcloud.net.cn/collocation/pages.html#customnav)。 |
\n
| backgroundColor | string (string.ColorString) |
\"
#ffffff
\"
| 否 | 下拉刷新显示出来的窗口的背景色(无下拉刷新时,此颜色无效果) |
\n
| backgroundColorContent | string (string.ColorString) | - | 否 | 页面容器背景色 |
\n
| enablePullDownRefresh | boolean | false | 否 | 是否开启下拉刷新,详见[页面生命周期](https://doc.dcloud.net.cn/uni-app-x/page.html)。 |"
},
"PagesOptionsPage"
:{
"compatibility"
:
"**PagesOptionsPage 兼容性**
\n
| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| path | 5.0 | √ | x | 4.0 |
\n
| style | 5.0 | √ | x | 4.0 |
\n
| needLogin | 5.0 | 3.99 | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| path | string (string.PageURIString) | - | 是 | 配置页面路径 |
\n
| style | [style 配置项列表](#pagesoptionspage-style) | - | 否 | - |
\n
| needLogin | boolean | false | 否 | 是否需要登录才可访问 |"
},
"PagesOptionsPage_style"
:{
"compatibility"
:
"**style 兼容性**
\n
| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| navigationBarBackgroundColor | 5.0 | √ | x | 4.0 |
\n
| navigationBarTextStyle | 5.0 | √ | x | 4.0 |
\n
| navigationBarTitleText | 5.0 | √ | x | 4.0 |
\n
| navigationStyle | 5.0 | √ | x | 4.0 |
\n
| backgroundColor | 5.0 | 3.99 | x | 4.0 |
\n
| backgroundColorContent | 5.0 | 4.0 | x | x |
\n
| enablePullDownRefresh | 5.0 | √ | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| navigationBarBackgroundColor | string (string.ColorString) | `app`: #F8F8F8<br/>`web`: #F8F8F8<br/>`mp-weixin、mp-qq、mp-baidu、mp-toutiao、mp-lark、mp-jd`: #000000<br/>`mp-alipay、mp-kuaishou`: #ffffff | 否 | 导航栏背景颜色(同状态栏背景色) |
\n
| navigationBarTextStyle | 'white'
\\
| 'black' |
\"
black
\"
| 否 | 导航栏标题颜色,仅支持 black/white |
\n
| navigationBarTitleText | string | - | 否 | 导航栏标题文字内容 |
\n
| navigationStyle | 'defaultValue'
\\
| 'custom' |
\"
defaultValue
\"
| 否 | 导航栏样式,仅支持 default/custom。custom即取消默认的原生导航栏,需看[使用注意](https://uniapp.dcloud.net.cn/collocation/pages.html#customnav)。 |
\n
| backgroundColor | string (string.ColorString) |
\"
#ffffff
\"
| 否 | 下拉刷新显示出来的窗口的背景色(无下拉刷新时,此颜色无效果) |
\n
| backgroundColorContent | string (string.ColorString) | - | 否 | 页面容器背景色 |
\n
| enablePullDownRefresh | boolean | false | 否 | 是否开启下拉刷新,详见[页面生命周期](https://doc.dcloud.net.cn/uni-app-x/page.html)。 |
\n
| h5 | [h5 配置项列表](#style-h5) | - | 否 | - |
\n
| mp-alipay | [mp-alipay 配置项列表](#style-mp-alipay) | - | 否 | - |"
},
"style_h5"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| titleNView | [titleNView 配置项列表](#h5-titlenview) | - | 否 | - |
\n
| pullToRefresh | [pullToRefresh 配置项列表](#h5-pulltorefresh) | - | 否 | - |"
},
"h5_titleNView"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| backgroundColor | string (string.ColorString) |
\"
#f7f7f7
\"
| 否 | 背景颜色,颜色值格式为
\"
#RRGGBB
\"
。 |
\n
| buttons | array | - | 否 | 自定义按钮,参考 [buttons](https://uniapp.dcloud.net.cn/collocation/pages.html?id=h5-titlenview-buttons)。 |
\n
| titleColor | string (string.ColorString) |
\"
#000000
\"
| 否 | 标题文字颜色 |
\n
| titleText | string | - | 否 | 标题文字内容 |
\n
| titleSize | string | - | 否 | 标题文字字体大小 |
\n
| type | 'defaultValue'
\\
| 'transparent' |
\"
defaultValue
\"
| 否 | 导航栏样式。
\"
default
\"
-默认样式;
\"
transparent
\"
-透明渐变。 |
\n
| searchInput | object | - | 否 | 导航栏上的搜索框样式,详见:[searchInput](https://uniapp.dcloud.net.cn/collocation/pages.html?id=h5-searchinput)。 |"
},
"h5_pullToRefresh"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| support | boolean | - | 否 | 是否开启窗口的下拉刷新功能 |
\n
| color | string (string.ColorString) | - | 否 | 颜色值格式为
\"
#RRGGBB
\"
,仅
\"
circle
\"
样式下拉刷新支持此属性。 |
\n
| type | 'defaultValue'
\\
| 'circle' | - | 否 | 下拉刷新控件样式 |
\n
| height | string | - | 否 | 窗口的下拉刷新控件进入刷新状态的拉拽高度。支持百分比,如
\"
10%
\"
;像素值,如
\"
50px
\"
。 |
\n
| range | string | - | 否 | 窗口可下拉拖拽的范围。支持百分比,如
\"
10%
\"
;像素值,如
\"
50px
\"
。 |
\n
| offset | string | - | 否 | 下拉刷新控件的起始位置。仅对
\"
circle
\"
样式下拉刷新控件有效,用于定义刷新控件下拉时的起始位置。支持百分比,如
\"
10%
\"
;像素值,如
\"
50px
\"
。 |
\n
| contentdown | [contentdown 配置项列表](#pulltorefresh-contentdown) | - | 否 | - |
\n
| contentover | [contentover 配置项列表](#pulltorefresh-contentover) | - | 否 | - |
\n
| contentrefresh | [contentrefresh 配置项列表](#pulltorefresh-contentrefresh) | - | 否 | - |"
},
"pullToRefresh_contentdown"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| caption | string | - | 否 | 下拉刷新控件上显示的标题内容 |"
},
"pullToRefresh_contentover"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| caption | string | - | 否 | 下拉刷新控件上显示的标题内容 |"
},
"pullToRefresh_contentrefresh"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| caption | string | - | 否 | 下拉刷新控件上显示的标题内容 |"
},
"style_mp-alipay"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| allowsBounceVertical | 'YES'
\\
| 'NO' |
\"
YES
\"
| 否 | 是否允许向下拉拽。支持 YES / NO |
\n
| transparentTitle | 'always'
\\
| 'auto'
\\
| 'none' |
\"
none
\"
| 否 | 导航栏透明设置。支持 always 一直透明 / auto 滑动自适应 / none 不透明 |
\n
| titlePenetrate | 'YES'
\\
| 'NO' |
\"
No
\"
| 否 | 导航栏点击穿透 |
\n
| showTitleLoading | 'YES'
\\
| 'NO' |
\"
No
\"
| 否 | 是否进入时显示导航栏的 loading。支持 YES / NO |
\n
| titleImage | string | - | 否 | 导航栏图片地址,替换导航栏标题,必须为https的图片链接地址 |
\n
| backgroundImageUrl | string (string.ImageURIString) | - | 否 | 下拉露出显示的背景图链接 |
\n
| backgroundImageColor | string (string.ColorString) | - | 否 | 下拉露出显示的背景图底色 |
\n
| gestureBack | 'YES'
\\
| 'NO' |
\"
No
\"
| 否 | 支付宝小程序 iOS 用,是否支持手势返回。支持 YES / NO |
\n
| enableScrollBar | 'YES'
\\
| 'NO' |
\"
YES
\"
| 否 | 支付宝小程序 Android 用,是否显示 WebView 滚动条。支持 YES / NO。 |"
},
"pages_tabBar"
:{
"compatibility"
:
"**tabBar 兼容性**
\n
| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| color | 5.0 | √ | x | 4.0 |
\n
| selectedColor | 5.0 | √ | x | 4.0 |
\n
| backgroundColor | 5.0 | √ | x | 4.0 |
\n
| list | 5.0 | √ | x | 4.0 |
\n
| backgroundImage | 5.0 | √ | x | 4.0 |
\n
| backgroundRepeat | 5.0 | √ | x | 4.0 |
\n
| redDotColor | 5.0 | √ | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| color | string (string.ColorString) | - | 是 | tab 上的文字默认颜色 |
\n
| selectedColor | string (string.ColorString) | - | 是 | tab 上的文字选中时的颜色 |
\n
| backgroundColor | string (string.ColorString) | - | 是 | tab 的背景色 |
\n
| list | Array
\\
<[PagesOptionsTabbarList](#pagesoptionstabbarlist)> | - | 是 | tab 的列表,详见 list 属性说明,最少2个、最多5个 tab |
\n
| backgroundImage | string | - | 否 | 设置背景图片,优先级高于 backgroundColor |
\n
| backgroundRepeat | 'repeat'
\\
| 'repeat-x'
\\
| 'repeat-y'
\\
| 'no-repeat' |
\"
no-repeat
\"
| 否 | 设置标题栏的背景图平铺方式 |
\n
| redDotColor | string (string.ColorString) | - | 否 | tabbar上红点颜色 |"
},
"PagesOptionsTabbarList"
:{
"compatibility"
:
"**PagesOptionsTabbarList 兼容性**
\n
| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| iconfont | 5.0 | √ | x | 4.0 |
\n
| pagePath | 5.0 | √ | x | 4.0 |
\n
| text | 5.0 | √ | x | 4.0 |
\n
| iconPath | 5.0 | √ | x | 4.0 |
\n
| selectedIconPath | 5.0 | √ | x | 4.0 |
\n
| visible | 5.0 | √ | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| iconfont | [iconfont 配置项列表](#pagesoptionstabbarlist-iconfont) | - | 否 | 字体图标,优先级高于 iconPath |
\n
| pagePath | string (string.PageURIString) | - | 是 | 页面路径,必须在 pages 中先定义 |
\n
| text | string | - | 是 | tab 上按钮文字,在 App 和 H5 平台为非必填。例如中间可放一个没有文字的+号图标 |
\n
| iconPath | string (string.ImageURIString) | - | 否 | 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 position 为 top 时,此参数无效,不支持网络图片,不支持字体图标 |
\n
| selectedIconPath | string (string.ImageURIString) | - | 否 | 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 position 为 top 时,此参数无效 |
\n
| visible | string | - | 否 | 该项是否显示,默认显示 |"
},
"PagesOptionsTabbarList_iconfont"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| text | string | - | 否 | 字库 Unicode 码 |
\n
| selectedText | string | - | 否 | 选中后字库 Unicode 码 |
\n
| fontSize | string | - | 否 | 字体图标字号(px) |
\n
| color | string (string.ColorString) | - | 否 | 字体图标颜色 |
\n
| selectedColor | string (string.ColorString) | - | 否 | 字体图标选中颜色 |"
,
"description"
:
"字体图标,优先级高于 iconPath"
},
"pages_condition"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| current | number | - | 是 | 当前激活的模式,list节点的索引值。 |
\n
| list | Array
\\
<[PagesConditionItem](#pagesconditionitem)> | - | 是 | 启动模式列表 |"
},
"PagesConditionItem"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string | - | 是 | 启动模式名称 |
\n
| path | string (string.PageURIString) | - | 是 | 启动页面路径 |
\n
| query | string | - | 否 | 启动参数,可在页面的 onLoad 函数里获得 |"
},
"pages_easycom"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| autoscan | boolean | true | 否 | 是否开启自动扫描,开启后将会自动扫描符合components/组件名称/组件名称.vue/uvue目录结构的组件 |
\n
| custom | object | - | 否 | 以正则方式自定义组件匹配规则。如果autoscan不能满足需求,可以使用custom自定义匹配规则 |"
,
"description"
:
"组件自动引入规则"
},
"pages_uniIdRouter"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| loginPage | string (string.PageURIString) | - | 否 | 登录页面路径 |
\n
| resToLogin | boolean | - | 否 | 是否开启自动根据响应体判断跳转登录页面,默认true(开启) |
\n
| needLogin | Array
\\
<string,string.PageURIString> | - | 否 | - |"
,
"description"
:
"根据用户登录状态、页面是否要求登录、以及接口返回的用户token验证状态自动跳转登录页面。详细教程:[详见](https://doc.dcloud.net.cn/uniCloud/uni-id/summary.html#uni-id-router)"
},
"tutorial"
:
"## 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=collocation.pages_json)"
}
\ No newline at end of file
{
"pages"
:{
"compatibility"
:
"**pages.json 兼容性**
\n
| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| globalStyle | √ | x | 4.0 |
\n
| pages | √ | x | 4.0 |
\n
| tabBar | √ | x | 4.0 |
\n
| condition | √ | x | 4.0 |
\n
| easycom | √ | x | 4.0 |
\n
| uniIdRouter | 3.99 | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| globalStyle | [globalStyle 配置项列表](#pages-globalstyle) | - | 否 | - |
\n
| pages | Array
\\
<[PagesOptionsPage](#pagesoptionspage)> | - | 是 | 页面路径及窗口表现 |
\n
| tabBar | [tabBar 配置项列表](#pages-tabbar) | - | 否 | - |
\n
| condition | [condition 配置项列表](#pages-condition) | - | 否 | - |
\n
| easycom | [easycom 配置项列表](#pages-easycom) | - | 否 | 组件自动引入规则 |
\n
| uniIdRouter | [uniIdRouter 配置项列表](#pages-uniidrouter) | - | 否 | 根据用户登录状态、页面是否要求登录、以及接口返回的用户token验证状态自动跳转登录页面。详细教程:[详见](https://doc.dcloud.net.cn/uniCloud/uni-id/summary.html#uni-id-router) |"
},
"pages_globalStyle"
:{
"compatibility"
:
"**globalStyle 兼容性**
\n
| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| navigationBarBackgroundColor | √ | x | 4.0 |
\n
| navigationBarTextStyle | √ | x | 4.0 |
\n
| navigationBarTitleText | √ | x | 4.0 |
\n
| navigationStyle | √ | x | 4.0 |
\n
| backgroundColor | 3.99 | x | 4.0 |
\n
| backgroundColorContent | 4.0 | x | x |
\n
| enablePullDownRefresh | √ | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| navigationBarBackgroundColor | string (string.ColorString) | `app`: #F8F8F8<br/>`web`: #F8F8F8<br/>`mp-weixin、mp-qq、mp-baidu、mp-toutiao、mp-lark、mp-jd`: #000000<br/>`mp-alipay、mp-kuaishou`: #ffffff | 否 | 导航栏背景颜色(同状态栏背景色) |
\n
| navigationBarTextStyle | 'white'
\\
| 'black' |
\"
black
\"
| 否 | 导航栏标题颜色,仅支持 black/white(支付宝小程序不支持,请使用 [my.setNavigationBar](https://opendocs.alipay.com/mini/api/xwq8e6))。 |
\n
| navigationBarTitleText | string | - | 否 | 导航栏标题文字内容 |
\n
| navigationStyle | 'defaultValue'
\\
| 'custom' |
\"
defaultValue
\"
| 否 | 导航栏样式,仅支持 default/custom。custom即取消默认的原生导航栏,需看[使用注意](https://uniapp.dcloud.net.cn/collocation/pages.html#customnav)。 |
\n
| backgroundColor | string (string.ColorString) |
\"
#ffffff
\"
| 否 | 下拉刷新显示出来的窗口的背景色(无下拉刷新时,此颜色无效果) |
\n
| backgroundColorContent | string (string.ColorString) | - | 否 | 页面容器背景色 |
\n
| enablePullDownRefresh | boolean | false | 否 | 是否开启下拉刷新,详见[页面生命周期](https://doc.dcloud.net.cn/uni-app-x/page.html)。 |"
},
"PagesOptionsPage"
:{
"compatibility"
:
"**PagesOptionsPage 兼容性**
\n
| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| path | √ | x | 4.0 |
\n
| style | √ | x | 4.0 |
\n
| needLogin | 3.99 | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| path | string (string.PageURIString) | - | 是 | 配置页面路径 |
\n
| style | [style 配置项列表](#pagesoptionspage-style) | - | 否 | - |
\n
| needLogin | boolean | false | 否 | 是否需要登录才可访问 |"
},
"PagesOptionsPage_style"
:{
"compatibility"
:
"**style 兼容性**
\n
| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| navigationBarBackgroundColor | √ | x | 4.0 |
\n
| navigationBarTextStyle | √ | x | 4.0 |
\n
| navigationBarTitleText | √ | x | 4.0 |
\n
| navigationStyle | √ | x | 4.0 |
\n
| backgroundColor | 3.99 | x | 4.0 |
\n
| backgroundColorContent | 4.0 | x | x |
\n
| enablePullDownRefresh | √ | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| navigationBarBackgroundColor | string (string.ColorString) | `app`: #F8F8F8<br/>`web`: #F8F8F8<br/>`mp-weixin、mp-qq、mp-baidu、mp-toutiao、mp-lark、mp-jd`: #000000<br/>`mp-alipay、mp-kuaishou`: #ffffff | 否 | 导航栏背景颜色(同状态栏背景色) |
\n
| navigationBarTextStyle | 'white'
\\
| 'black' |
\"
black
\"
| 否 | 导航栏标题颜色,仅支持 black/white |
\n
| navigationBarTitleText | string | - | 否 | 导航栏标题文字内容 |
\n
| navigationStyle | 'defaultValue'
\\
| 'custom' |
\"
defaultValue
\"
| 否 | 导航栏样式,仅支持 default/custom。custom即取消默认的原生导航栏,需看[使用注意](https://uniapp.dcloud.net.cn/collocation/pages.html#customnav)。 |
\n
| backgroundColor | string (string.ColorString) |
\"
#ffffff
\"
| 否 | 下拉刷新显示出来的窗口的背景色(无下拉刷新时,此颜色无效果) |
\n
| backgroundColorContent | string (string.ColorString) | - | 否 | 页面容器背景色 |
\n
| enablePullDownRefresh | boolean | false | 否 | 是否开启下拉刷新,详见[页面生命周期](https://doc.dcloud.net.cn/uni-app-x/page.html)。 |
\n
| h5 | [h5 配置项列表](#style-h5) | - | 否 | - |
\n
| mp-alipay | [mp-alipay 配置项列表](#style-mp-alipay) | - | 否 | - |"
},
"style_h5"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| titleNView | [titleNView 配置项列表](#h5-titlenview) | - | 否 | - |
\n
| pullToRefresh | [pullToRefresh 配置项列表](#h5-pulltorefresh) | - | 否 | - |"
},
"h5_titleNView"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| backgroundColor | string (string.ColorString) |
\"
#f7f7f7
\"
| 否 | 背景颜色,颜色值格式为
\"
#RRGGBB
\"
。 |
\n
| buttons | array | - | 否 | 自定义按钮,参考 [buttons](https://uniapp.dcloud.net.cn/collocation/pages.html?id=h5-titlenview-buttons)。 |
\n
| titleColor | string (string.ColorString) |
\"
#000000
\"
| 否 | 标题文字颜色 |
\n
| titleText | string | - | 否 | 标题文字内容 |
\n
| titleSize | string | - | 否 | 标题文字字体大小 |
\n
| type | 'defaultValue'
\\
| 'transparent' |
\"
defaultValue
\"
| 否 | 导航栏样式。
\"
default
\"
-默认样式;
\"
transparent
\"
-透明渐变。 |
\n
| searchInput | object | - | 否 | 导航栏上的搜索框样式,详见:[searchInput](https://uniapp.dcloud.net.cn/collocation/pages.html?id=h5-searchinput)。 |"
},
"h5_pullToRefresh"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| support | boolean | - | 否 | 是否开启窗口的下拉刷新功能 |
\n
| color | string (string.ColorString) | - | 否 | 颜色值格式为
\"
#RRGGBB
\"
,仅
\"
circle
\"
样式下拉刷新支持此属性。 |
\n
| type | 'defaultValue'
\\
| 'circle' | - | 否 | 下拉刷新控件样式 |
\n
| height | string | - | 否 | 窗口的下拉刷新控件进入刷新状态的拉拽高度。支持百分比,如
\"
10%
\"
;像素值,如
\"
50px
\"
。 |
\n
| range | string | - | 否 | 窗口可下拉拖拽的范围。支持百分比,如
\"
10%
\"
;像素值,如
\"
50px
\"
。 |
\n
| offset | string | - | 否 | 下拉刷新控件的起始位置。仅对
\"
circle
\"
样式下拉刷新控件有效,用于定义刷新控件下拉时的起始位置。支持百分比,如
\"
10%
\"
;像素值,如
\"
50px
\"
。 |
\n
| contentdown | [contentdown 配置项列表](#pulltorefresh-contentdown) | - | 否 | - |
\n
| contentover | [contentover 配置项列表](#pulltorefresh-contentover) | - | 否 | - |
\n
| contentrefresh | [contentrefresh 配置项列表](#pulltorefresh-contentrefresh) | - | 否 | - |"
},
"pullToRefresh_contentdown"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| caption | string | - | 否 | 下拉刷新控件上显示的标题内容 |"
},
"pullToRefresh_contentover"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| caption | string | - | 否 | 下拉刷新控件上显示的标题内容 |"
},
"pullToRefresh_contentrefresh"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| caption | string | - | 否 | 下拉刷新控件上显示的标题内容 |"
},
"style_mp-alipay"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| allowsBounceVertical | 'YES'
\\
| 'NO' |
\"
YES
\"
| 否 | 是否允许向下拉拽。支持 YES / NO |
\n
| transparentTitle | 'always'
\\
| 'auto'
\\
| 'none' |
\"
none
\"
| 否 | 导航栏透明设置。支持 always 一直透明 / auto 滑动自适应 / none 不透明 |
\n
| titlePenetrate | 'YES'
\\
| 'NO' |
\"
No
\"
| 否 | 导航栏点击穿透 |
\n
| showTitleLoading | 'YES'
\\
| 'NO' |
\"
No
\"
| 否 | 是否进入时显示导航栏的 loading。支持 YES / NO |
\n
| titleImage | string | - | 否 | 导航栏图片地址,替换导航栏标题,必须为https的图片链接地址 |
\n
| backgroundImageUrl | string (string.ImageURIString) | - | 否 | 下拉露出显示的背景图链接 |
\n
| backgroundImageColor | string (string.ColorString) | - | 否 | 下拉露出显示的背景图底色 |
\n
| gestureBack | 'YES'
\\
| 'NO' |
\"
No
\"
| 否 | 支付宝小程序 iOS 用,是否支持手势返回。支持 YES / NO |
\n
| enableScrollBar | 'YES'
\\
| 'NO' |
\"
YES
\"
| 否 | 支付宝小程序 Android 用,是否显示 WebView 滚动条。支持 YES / NO。 |"
},
"pages_tabBar"
:{
"compatibility"
:
"**tabBar 兼容性**
\n
| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| color | √ | x | 4.0 |
\n
| selectedColor | √ | x | 4.0 |
\n
| backgroundColor | √ | x | 4.0 |
\n
| list | √ | x | 4.0 |
\n
| backgroundImage | √ | x | 4.0 |
\n
| backgroundRepeat | √ | x | 4.0 |
\n
| redDotColor | √ | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| color | string (string.ColorString) | - | 是 | tab 上的文字默认颜色 |
\n
| selectedColor | string (string.ColorString) | - | 是 | tab 上的文字选中时的颜色 |
\n
| backgroundColor | string (string.ColorString) | - | 是 | tab 的背景色 |
\n
| list | Array
\\
<[PagesOptionsTabbarList](#pagesoptionstabbarlist)> | - | 是 | tab 的列表,详见 list 属性说明,最少2个、最多5个 tab |
\n
| backgroundImage | string | - | 否 | 设置背景图片,优先级高于 backgroundColor |
\n
| backgroundRepeat | 'repeat'
\\
| 'repeat-x'
\\
| 'repeat-y'
\\
| 'no-repeat' |
\"
no-repeat
\"
| 否 | 设置标题栏的背景图平铺方式 |
\n
| redDotColor | string (string.ColorString) | - | 否 | tabbar上红点颜色 |"
},
"PagesOptionsTabbarList"
:{
"compatibility"
:
"**PagesOptionsTabbarList 兼容性**
\n
| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| iconfont | √ | x | 4.0 |
\n
| pagePath | √ | x | 4.0 |
\n
| text | √ | x | 4.0 |
\n
| iconPath | √ | x | 4.0 |
\n
| selectedIconPath | √ | x | 4.0 |
\n
| visible | √ | x | 4.0 |"
,
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| iconfont | [iconfont 配置项列表](#pagesoptionstabbarlist-iconfont) | - | 否 | 字体图标,优先级高于 iconPath |
\n
| pagePath | string (string.PageURIString) | - | 是 | 页面路径,必须在 pages 中先定义 |
\n
| text | string | - | 是 | tab 上按钮文字,在 App 和 H5 平台为非必填。例如中间可放一个没有文字的+号图标 |
\n
| iconPath | string (string.ImageURIString) | - | 否 | 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 position 为 top 时,此参数无效,不支持网络图片,不支持字体图标 |
\n
| selectedIconPath | string (string.ImageURIString) | - | 否 | 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 position 为 top 时,此参数无效 |
\n
| visible | string | - | 否 | 该项是否显示,默认显示 |"
},
"PagesOptionsTabbarList_iconfont"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| text | string | - | 否 | 字库 Unicode 码 |
\n
| selectedText | string | - | 否 | 选中后字库 Unicode 码 |
\n
| fontSize | string | - | 否 | 字体图标字号(px) |
\n
| color | string (string.ColorString) | - | 否 | 字体图标颜色 |
\n
| selectedColor | string (string.ColorString) | - | 否 | 字体图标选中颜色 |"
,
"description"
:
"字体图标,优先级高于 iconPath"
},
"pages_condition"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| current | number | - | 是 | 当前激活的模式,list节点的索引值。 |
\n
| list | Array
\\
<[PagesConditionItem](#pagesconditionitem)> | - | 是 | 启动模式列表 |"
},
"PagesConditionItem"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string | - | 是 | 启动模式名称 |
\n
| path | string (string.PageURIString) | - | 是 | 启动页面路径 |
\n
| query | string | - | 否 | 启动参数,可在页面的 onLoad 函数里获得 |"
},
"pages_easycom"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| autoscan | boolean | true | 否 | 是否开启自动扫描,开启后将会自动扫描符合components/组件名称/组件名称.vue/uvue目录结构的组件 |
\n
| custom | object | - | 否 | 以正则方式自定义组件匹配规则。如果autoscan不能满足需求,可以使用custom自定义匹配规则 |"
,
"description"
:
"组件自动引入规则"
},
"pages_uniIdRouter"
:{
"table"
:
"| 属性 | 类型 | 默认值 | 必填 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| loginPage | string (string.PageURIString) | - | 否 | 登录页面路径 |
\n
| resToLogin | boolean | - | 否 | 是否开启自动根据响应体判断跳转登录页面,默认true(开启) |
\n
| needLogin | Array
\\
<string,string.PageURIString> | - | 否 | - |"
,
"description"
:
"根据用户登录状态、页面是否要求登录、以及接口返回的用户token验证状态自动跳转登录页面。详细教程:[详见](https://doc.dcloud.net.cn/uniCloud/uni-id/summary.html#uni-id-router)"
},
"tutorial"
:
"## 参见
\n
[相关 Bug](https://issues.dcloud.net.cn/?mid=collocation.pages_json)"
}
\ No newline at end of file
docs/.vuepress/utils/utsApiJson.json
浏览文件 @
f99a1eeb
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
docs/.vuepress/utils/utsComJson.json
浏览文件 @
f99a1eeb
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
docs/.vuepress/utils/utsJson.json
浏览文件 @
f99a1eeb
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
docs/.vuepress/utils/utsUnicloudApiJson.json
浏览文件 @
f99a1eeb
{
"uniCloud_props"
:{
"name"
:
"# uniCloud"
,
"description"
:
""
,
"param"
:
"## 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| config | [UniCloudInitOptions](#unicloudinitoptions-values) | 是 | - | - |
\n
### UniCloudInitOptions 的属性值 @unicloudinitoptions-values
\n\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
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"callFunction"
:{
"name"
:
"## callFunction(options) @callfunction"
,
"description"
:
"请求云函数"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudCallFunctionOptions](#unicloudcallfunctionoptions-values) | 是 | - | - |
\n
#### UniCloudCallFunctionOptions 的属性值 @unicloudcallfunctionoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string (string.CloudFunctionString) | 是 | - | 云函数名 |
\n
| data | any | 否 | - | 云函数参数 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudCallFunctionResult](#unicloudcallfunctionresult-values)> |
\n\n
#### UniCloudCallFunctionResult 的属性值 @unicloudcallfunctionresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| result | any | 是 | - | 云函数参数 |
\n
| requestId | string | 否 | - | 云函数请求id |
\n
"
,
"compatibility"
:
"### callFunction 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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
```html
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view style=
\"
flex: 1
\"
>
\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
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n
<script>
\n
export default {
\n
data() {
\n
return {
\n
title: '请求云函数',
\n
callFunctionResult: {},
\n
callFunctionError: {},
\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
uni.showToast({
\n
title: content
\n
})
\n
console.log(title, content)
\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
</script>
\n\n
<style>
\n
</style>
\n\n
```"
},
"importObject"
:{
"name"
:
"## importObject(objectName, options?) @importobject"
,
"description"
:
"引用云对象"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| objectName | string (string.CloudObjectString) | 是 | - | - |
\n
| options | [UniCloudImportObjectOptions](#unicloudimportobjectoptions-values) | 否 | - | - |
\n
#### UniCloudImportObjectOptions 的属性值 @unicloudimportobjectoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| customUI | boolean | 否 | - | 是否移除自动展示的ui |
\n
| loadingOptions | [UniCloudImportObjectLoadingOptions](#unicloudimportobjectloadingoptions-values) | 否 | - | loading界面配置 |
\n
| errorOptions | [UniCloudImportObjectErrorOptions](#unicloudimportobjecterroroptions-values) | 否 | - | 错误提示配置 |
\n\n
##### UniCloudImportObjectLoadingOptions 的属性值 @unicloudimportobjectloadingoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| title | string | 否 | - | 加载框标题 |
\n
| mask | boolean | 否 | - | 加载框是否显示mask |
\n\n
##### UniCloudImportObjectErrorOptions 的属性值 @unicloudimportobjecterroroptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 否 | - | 错误提示类型,可以是modal或者toast |
\n
| retry | boolean | 否 | - | 是否显示重试按钮 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
"
,
"compatibility"
:
"### importObject 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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
```html
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view style=
\"
flex:1
\"
>
\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=
\"
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=
\"
success
\"
>云对象成功调用</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n
<script>
\n
export default {
\n
data() {
\n
return {
\n
title: '请求云对象',
\n
todoTitle: '学习编程',
\n
todoContent: '熟悉uts语法',
\n
returnTodoTitle: '',
\n
returnTodoContent: '',
\n
failErrCode: '',
\n
successErrCode: -1,
\n
isUniTest: false
\n
}
\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
uni.showToast({
\n
title: content
\n
})
\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(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
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
if (this.isUniTest) {
\n
uni.showToast({
\n
title: error.errMsg
\n
})
\n
}
\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
</script>
\n\n
<style>
\n\n
</style>
\n\n
```"
},
"uploadFile"
:{
"name"
:
"## uploadFile(options) @uploadfile"
,
"description"
:
"上传文件到云存储"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudUploadFileOptions](#uniclouduploadfileoptions-values) | 是 | - | - |
\n
#### UniCloudUploadFileOptions 的属性值 @uniclouduploadfileoptions-values
\n\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](#uniclouduploadprogress-values) | 是 | - | 上传进度回调参数 |
\n
###### UniCloudUploadProgress 的属性值 @uniclouduploadprogress-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| loaded | number | 是 | - | 已上传大小 |
\n
| total | number | 是 | - | 总大小 |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n\n\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudUploadFileResult](#uniclouduploadfileresult-values)> |
\n\n
#### UniCloudUploadFileResult 的属性值 @uniclouduploadfileresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filePath | string | 是 | - | 文件路径 |
\n
| fileID | string | 是 | - | 文件id |
\n
"
,
"compatibility"
:
"### uploadFile 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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](#unicloudgettempfileurloptions-values) | 是 | - | - |
\n
#### UniCloudGetTempFileURLOptions 的属性值 @unicloudgettempfileurloptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| fileList | Array
\\
<string
\\
> | 是 | - | 文件列表 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudGetTempFileURLResult](#unicloudgettempfileurlresult-values)> |
\n\n
#### UniCloudGetTempFileURLResult 的属性值 @unicloudgettempfileurlresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| fileList | Array
\\
<[UniCloudGetTempFileURLResultItem](#unicloudgettempfileurlresultitem-values)
\\
> | 是 | - | 文件列表 |
\n\n
##### UniCloudGetTempFileURLResultItem 的属性值 @unicloudgettempfileurlresultitem-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| fileID | string | 是 | - | 文件id |
\n
| tempFileURL | string | 是 | - | 文件临时url |
\n
"
,
"compatibility"
:
"### getTempFileURL 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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
#### UniCloudChooseAndUploadFileOptions 的属性值 @unicloudchooseanduploadfileoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| sourceType | Array
\\
<string
\\
> | 否 | - | - |
\n
| count | number | 否 | - | - |
\n
| sizeType | Array
\\
<string
\\
> | 否 | - | - |
\n
| extension | Array
\\
<string
\\
> | 否 | - | - |
\n
| compressed | boolean | 否 | - | - |
\n
| maxDuration | number | 否 | - | - |
\n
| camera | string | 否 | - | - |
\n
| crop | ChooseImageCropOptions | 否 | - | - |
\n
| type | string | 是 | - | - |
\n\n
#### UniCloudChooseAndUploadFileOptions 的方法 @unicloudchooseanduploadfileoptions-values
\n\n
#### onChooseFile(arg) @onchoosefile
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | [UniCloudChooseFileResult](#unicloudchoosefileresult-values) | 是 | - | - |
\n
###### UniCloudChooseFileResult 的属性值 @unicloudchoosefileresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFiles | Array
\\
<[UniCloudChooseFileItem](#unicloudchoosefileitem-values)
\\
> | 是 | - | - |
\n
| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - |
\n\n
###### UniCloudChooseFileItem 的属性值 @unicloudchoosefileitem-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string | 是 | - | - |
\n
| path | string | 是 | - | - |
\n
| cloudPath | string | 是 | - | - |
\n
| cloudPathAsRealPath | boolean | 否 | - | - |
\n
| url | string | 否 | - | - |
\n
| errMsg | string | 否 | - | - |
\n\n\n\n\n
#### onUploadProgress(arg) @onuploadprogress
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | [UniCloudChooseAndUploadFileProgressEvent](#unicloudchooseanduploadfileprogressevent-values) | 是 | - | - |
\n
###### UniCloudChooseAndUploadFileProgressEvent 的属性值 @unicloudchooseanduploadfileprogressevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| index | number | 是 | - | - |
\n
| loaded | number | 是 | - | - |
\n
| total | number | 是 | - | - |
\n
| tempFilePath | string | 是 | - | - |
\n
| tempFile | [UniCloudChooseFileItem](#unicloudchoosefileitem-values) | 是 | - | - |
\n\n\n\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudChooseAndUploadFileResult](#unicloudchooseanduploadfileresult-values)> |
\n\n
#### UniCloudChooseAndUploadFileResult 的属性值 @unicloudchooseanduploadfileresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFiles | Array
\\
<[UniCloudChooseFileItem](#unicloudchoosefileitem-values)
\\
> | 是 | - | - |
\n
| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - |
\n\n
##### UniCloudChooseFileItem 的属性值 @unicloudchoosefileitem-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string | 是 | - | - |
\n
| path | string | 是 | - | - |
\n
| cloudPath | string | 是 | - | - |
\n
| cloudPathAsRealPath | boolean | 否 | - | - |
\n
| url | string | 否 | - | - |
\n
| errMsg | string | 否 | - | - |
\n
"
,
"compatibility"
:
"### chooseAndUploadFile 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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
```html
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view style=
\"
flex: 1
\"
>
\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
<script>
\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
</script>
\n\n
<style>
\n
</style>
\n\n
```"
},
"databaseForJQL"
:{
"name"
:
"## databaseForJQL() @databaseforjql"
,
"description"
:
"获取数据库操作实例"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Database](#database-values) |
\n\n
#### Database 的属性值 @database-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| command | any | 是 | - | - |
\n
| Geo | any | 是 | - | - |
\n\n
#### Database 的方法 @database-values
\n\n
#### collection(args?) @collection
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - |
\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
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n
###### UniCloudDBFilter 的方法 @uniclouddbfilter-values
\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any | 否 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n\n
###### UniCloudDBGetResult 的属性值 @uniclouddbgetresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| data | Array
\\
<any
\\
> | 是 | - | etResult = { /** |
\n
| count | number | 否 | - | JSONObject>; /** |
\n
| requestId | string | 否 | - | ber
\\
| null; / |
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n\n
###### UniCloudDBCountResult 的属性值 @uniclouddbcountresult-values
\n\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
| Promise<[UniCloudDBUpdateResult](#uniclouddbupdateresult-values)> |
\n\n
###### UniCloudDBUpdateResult 的属性值 @uniclouddbupdateresult-values
\n\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](#uniclouddbremoveresult-values)> |
\n\n
###### UniCloudDBRemoveResult 的属性值 @uniclouddbremoveresult-values
\n\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
##### where(condition) @where
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| condition | any | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### doc(docId) @doc
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| docId | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\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 | 否 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### groupBy(field) @groupby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### groupField(field) @groupfield
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### distinct(field) @distinct
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### geoNear(options) @geonear
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | any | 是 | - | 云函数参数 |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### groupBy(field) @groupby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### groupField(field) @groupfield
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### distinct(field) @distinct
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### geoNear(options) @geonear
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | any | 是 | - | 云函数参数 |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n\n\n
##### doc(docId) @doc
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| docId | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### aggregate() @aggregate
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### foreignKey(foreignKey) @foreignkey
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| foreignKey | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### add(data) @add
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| data | any | 是 | - | 云函数参数 |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBAddResult](#uniclouddbaddresult-values)> |
\n\n
###### UniCloudDBAddResult 的属性值 @uniclouddbaddresult-values
\n\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 | 否 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n\n
"
,
"compatibility"
:
"### databaseForJQL 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.91,腾讯云 3.91 | - | x | - |
\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
```html
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view style=
\"
flex: 1
\"
>
\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
<script>
\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
onLoad() {
\n
},
\n
onUnload() {
\n
if (this.isUniTest) {
\n
uni.hideToast()
\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
uni.showToast({
\n
title: content
\n
})
\n
console.error(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
</script>
\n\n
<style>
\n
</style>
\n\n
```"
},
"onResponse"
:{
"name"
:
"## onResponse(callback) @onresponse"
,
"description"
:
"监听响应事件"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any | 是 | - | - |
\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### onResponse 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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 | 是 | - | - |
\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### offResponse 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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 | 是 | - | - |
\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### onRefreshToken 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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 | 是 | - | - |
\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 是 | - | 响应事件类型 |
\n
| name | string | 是 | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
"### offRefreshToken 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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](#uniclouduserinfo-values) |
\n\n
#### UniCloudUserInfo 的属性值 @uniclouduserinfo-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| uid | string | 否 | - | UserInfo = { / |
\n
| role | Array
\\
<string
\\
> | 是 | - | ing
\\
| null; / |
\n
| permission | Array
\\
<string
\\
> | 是 | - | ay
\\
<string>; / |
\n
| tokenExpired | number | 是 | - | ay
\\
<string>; /** |
\n
"
,
"compatibility"
:
"### getCurrentUserInfo 兼容性
\n
| 安卓系统版本 | 安卓 | iOS 系统版本 | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| 5.0 | 阿里云 3.9,腾讯云 3.91 | - | x | - |
\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
{
"uniCloud_props"
:{
"name"
:
"# uniCloud"
,
"description"
:
""
,
"param"
:
"## 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| config | [UniCloudInitOptions](#unicloudinitoptions-values) | 是 | - | - |
\n
| mixinDatacom | any | 是 | - | - |
\n
### UniCloudInitOptions 的属性值 @unicloudinitoptions-values
\n\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
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"callFunction"
:{
"name"
:
"## callFunction(options) @callfunction"
,
"description"
:
"请求云函数"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudCallFunctionOptions](#unicloudcallfunctionoptions-values) | 是 | - | - |
\n
#### UniCloudCallFunctionOptions 的属性值 @unicloudcallfunctionoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string (string.CloudFunctionString) | 是 | - | 云函数名 |
\n
| data | any | 否 | - | 云函数参数 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudCallFunctionResult](#unicloudcallfunctionresult-values)> |
\n\n
#### UniCloudCallFunctionResult 的属性值 @unicloudcallfunctionresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| result | any | 是 | - | 云函数返回结果 |
\n
| requestId | string | 否 | - | 云函数请求id |
\n
"
,
"compatibility"
:
"### callFunction 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91 | x | - |
\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>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view class=
\"
page-scroll-view
\"
>
\r\n
<!-- #endif -->
\r\n
<view>
\r\n
<page-head :title=
\"
title
\"
></page-head>
\r\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@click=
\"
callFunction
\"
>请求云函数</button>
\r\n
</view>
\r\n
</view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n\r\n\r\n
<style>
\r\n
</style>
\r\n\n
```
\n
>Script
\n
```uts
\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
title: '请求云函数',
\r\n
callFunctionResult: {},
\r\n
callFunctionError: {},
\r\n
isUniTest: false
\r\n
}
\r\n
},
\r\n
onLoad() {
\r\n
},
\r\n
onUnload() {
\r\n
if (this.isUniTest) {
\r\n
uni.hideToast()
\r\n
}
\r\n
},
\r\n
methods: {
\r\n
notify(content : string, title : string) {
\r\n
if (!this.isUniTest) {
\r\n
uni.showModal({
\r\n
title,
\r\n
content,
\r\n
showCancel: false
\r\n
})
\r\n
} else {
\r\n
uni.showToast({
\r\n
title: content
\r\n
})
\r\n
console.log(title, content)
\r\n
}
\r\n
},
\r\n
async callFunction() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
await uniCloud.callFunction({
\r\n
name: 'echo-cf',
\r\n
data: {
\r\n
num: 1,
\r\n
str: 'ABC'
\r\n
}
\r\n
}).then(res => {
\r\n
const result = res.result
\r\n
this.callFunctionResult = result
\r\n
console.log(JSON.stringify(result))
\r\n
uni.hideLoading()
\r\n
this.notify(result['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
this.callFunctionError = {
\r\n
errCode: error.errCode,
\r\n
errMsg: error.errMsg
\r\n
}
\r\n
uni.hideLoading()
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
}
\r\n
}
\r\n
}
\r\n\n
```
\n\n
:::"
},
"importObject"
:{
"name"
:
"## importObject(objectName, options?) @importobject"
,
"description"
:
"引用云对象"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| objectName | string (string.CloudObjectString) | 是 | - | - |
\n
| options | [UniCloudImportObjectOptions](#unicloudimportobjectoptions-values) | 否 | - | - |
\n
#### UniCloudImportObjectOptions 的属性值 @unicloudimportobjectoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| customUI | boolean | 否 | - | 是否移除自动展示的ui |
\n
| loadingOptions | [UniCloudImportObjectLoadingOptions](#unicloudimportobjectloadingoptions-values) | 否 | - | loading界面配置 |
\n
| errorOptions | [UniCloudImportObjectErrorOptions](#unicloudimportobjecterroroptions-values) | 否 | - | 错误提示配置 |
\n\n
##### UniCloudImportObjectLoadingOptions 的属性值 @unicloudimportobjectloadingoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| title | string | 否 | - | 加载框标题 |
\n
| mask | boolean | 否 | - | 加载框是否显示mask |
\n\n
##### UniCloudImportObjectErrorOptions 的属性值 @unicloudimportobjecterroroptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| type | string | 否 | - | 错误提示类型,可以是modal或者toast |
\n
| retry | boolean | 否 | - | 是否显示重试按钮 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
"
,
"compatibility"
:
"### importObject 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91 | x | - |
\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>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view class=
\"
page-scroll-view
\"
>
\r\n
<!-- #endif -->
\r\n
<view>
\r\n
<page-head :title=
\"
title
\"
></page-head>
\r\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
addTodo
\"
>添加Todo</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
randomFail
\"
>随机触发失败重试</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
fail
\"
>云对象失败调用</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
success
\"
>云对象成功调用</button>
\r\n
</view>
\r\n
</view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n\r\n\r\n
<style>
\r\n\r\n
</style>
\r\n\n
```
\n
>Script
\n
```uts
\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
title: '请求云对象',
\r\n
todoTitle: '学习编程',
\r\n
todoContent: '熟悉uts语法',
\r\n
returnTodoTitle: '',
\r\n
returnTodoContent: '',
\r\n
failErrCode: '',
\r\n
successErrCode: -1,
\r\n
isUniTest: false
\r\n
}
\r\n
},
\r\n
onUnload() {
\r\n
if (this.isUniTest) {
\r\n
uni.hideToast()
\r\n
}
\r\n
},
\r\n
methods: {
\r\n
notify(content : string, title : string) {
\r\n
if (!this.isUniTest) {
\r\n
uni.showModal({
\r\n
title,
\r\n
content,
\r\n
showCancel: false
\r\n
})
\r\n
} else {
\r\n
uni.showToast({
\r\n
title: content
\r\n
})
\r\n
console.log(title, content)
\r\n
}
\r\n
},
\r\n
async addTodo() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
const title = this.todoTitle
\r\n
const content = this.todoContent
\r\n
await todo.add(title, content).then((res : UTSJSONObject) => {
\r\n
this.returnTodoTitle = res['title'] as string
\r\n
this.returnTodoContent = res['content'] as string
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async randomFail() : Promise<void> {
\r\n
const todoObj = uniCloud.importObject('todo', {
\r\n
errorOptions: {
\r\n
retry: true
\r\n
}
\r\n
})
\r\n
await todoObj.randomFail().then((res : UTSJSONObject) => {
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async fail() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
await todo.fail().then((res : UTSJSONObject) => {
\r\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\r\n
console.log('todo.fail: ', res);
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
this.failErrCode = error.errCode as string
\r\n
console.error(error)
\r\n
if (this.isUniTest) {
\r\n
uni.showToast({
\r\n
title: error.errMsg
\r\n
})
\r\n
}
\r\n
})
\r\n
},
\r\n
async success() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
await todo.success().then((res : UTSJSONObject) => {
\r\n
this.successErrCode = res['errCode'] as number
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
}
\r\n
}
\r\n
}
\r\n\n
```
\n\n
:::"
},
"uploadFile"
:{
"name"
:
"## uploadFile(options) @uploadfile"
,
"description"
:
"上传文件到云存储"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudUploadFileOptions](#uniclouduploadfileoptions-values) | 是 | - | - |
\n
#### UniCloudUploadFileOptions 的属性值 @uniclouduploadfileoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filePath | string | 是 | - | 文件路径 |
\n
| cloudPath | string | 是 | - | 云端路径 |
\n
| cloudPathAsRealPath | boolean | 否 | - | 是否以云端路径是否为真实路径保存上传的文件 |
\n\n
#### UniCloudUploadFileOptions 的方法 @uniclouduploadfileoptions-values
\n\n
#### onUploadProgress(options) @onuploadprogress
\n\r\n
上传进度回调
\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | [UniCloudUploadProgress](#uniclouduploadprogress-values) | 是 | - | 上传进度回调参数 |
\n
###### UniCloudUploadProgress 的属性值 @uniclouduploadprogress-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| loaded | number | 是 | - | 已上传大小 |
\n
| total | number | 是 | - | 总大小 |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n\n\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudUploadFileResult](#uniclouduploadfileresult-values)> |
\n\n
#### UniCloudUploadFileResult 的属性值 @uniclouduploadfileresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filePath | string | 是 | - | 文件路径 |
\n
| fileID | string | 是 | - | 文件id |
\n
"
,
"compatibility"
:
"### uploadFile 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91 | x | - |
\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](#unicloudgettempfileurloptions-values) | 是 | - | - |
\n
#### UniCloudGetTempFileURLOptions 的属性值 @unicloudgettempfileurloptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| fileList | Array
\\
<string
\\
> | 是 | - | 文件列表 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudGetTempFileURLResult](#unicloudgettempfileurlresult-values)> |
\n\n
#### UniCloudGetTempFileURLResult 的属性值 @unicloudgettempfileurlresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| fileList | Array
\\
<[UniCloudGetTempFileURLResultItem](#unicloudgettempfileurlresultitem-values)
\\
> | 是 | - | 文件列表 |
\n\n
##### UniCloudGetTempFileURLResultItem 的属性值 @unicloudgettempfileurlresultitem-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| fileID | string | 是 | - | 文件id |
\n
| tempFileURL | string | 是 | - | 文件临时url |
\n
"
,
"compatibility"
:
"### getTempFileURL 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91 | x | - |
\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
#### UniCloudChooseAndUploadFileOptions 的属性值 @unicloudchooseanduploadfileoptions-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| sourceType | Array
\\
<string
\\
> | 否 | - | - |
\n
| count | number | 否 | - | - |
\n
| sizeType | Array
\\
<string
\\
> | 否 | - | - |
\n
| extension | Array
\\
<string
\\
> | 否 | - | - |
\n
| compressed | boolean | 否 | - | - |
\n
| maxDuration | number | 否 | - | - |
\n
| camera | string | 否 | - | - |
\n
| crop | ChooseImageCropOptions | 否 | - | - |
\n
| type | string | 是 | - | - |
\n\n
#### UniCloudChooseAndUploadFileOptions 的方法 @unicloudchooseanduploadfileoptions-values
\n\n
#### onChooseFile(arg) @onchoosefile
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | [UniCloudChooseFileResult](#unicloudchoosefileresult-values) | 是 | - | - |
\n
###### UniCloudChooseFileResult 的属性值 @unicloudchoosefileresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFiles | Array
\\
<[UniCloudChooseFileItem](#unicloudchoosefileitem-values)
\\
> | 是 | - | - |
\n
| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - |
\n\n
###### UniCloudChooseFileItem 的属性值 @unicloudchoosefileitem-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string | 是 | - | - |
\n
| path | string | 是 | - | - |
\n
| cloudPath | string | 是 | - | - |
\n
| cloudPathAsRealPath | boolean | 否 | - | - |
\n
| url | string | 否 | - | - |
\n
| errMsg | string | 否 | - | - |
\n\n\n\n\n
#### onUploadProgress(arg) @onuploadprogress
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | [UniCloudChooseAndUploadFileProgressEvent](#unicloudchooseanduploadfileprogressevent-values) | 是 | - | - |
\n
###### UniCloudChooseAndUploadFileProgressEvent 的属性值 @unicloudchooseanduploadfileprogressevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| index | number | 是 | - | - |
\n
| loaded | number | 是 | - | - |
\n
| total | number | 是 | - | - |
\n
| tempFilePath | string | 是 | - | - |
\n
| tempFile | [UniCloudChooseFileItem](#unicloudchoosefileitem-values) | 是 | - | - |
\n\n\n\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudChooseAndUploadFileResult](#unicloudchooseanduploadfileresult-values)> |
\n\n
#### UniCloudChooseAndUploadFileResult 的属性值 @unicloudchooseanduploadfileresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| tempFiles | Array
\\
<[UniCloudChooseFileItem](#unicloudchoosefileitem-values)
\\
> | 是 | - | - |
\n
| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - |
\n\n
##### UniCloudChooseFileItem 的属性值 @unicloudchoosefileitem-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| name | string | 是 | - | - |
\n
| path | string | 是 | - | - |
\n
| cloudPath | string | 是 | - | - |
\n
| cloudPathAsRealPath | boolean | 否 | - | - |
\n
| url | string | 否 | - | - |
\n
| errMsg | string | 否 | - | - |
\n
"
,
"compatibility"
:
"### chooseAndUploadFile 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.9,腾讯云 3.91 | x | - |
\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>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view class=
\"
page-scroll-view
\"
>
\r\n
<!-- #endif -->
\r\n
<view>
\r\n
<page-head :title=
\"
title
\"
></page-head>
\r\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@click=
\"
uploadFile
\"
>选择文件上传</button>
\r\n
</view>
\r\n
</view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n\r\n
<style>
\r\n
</style>
\r\n\n
```
\n
>Script
\n
```uts
\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
title: '云存储'
\r\n
}
\r\n
},
\r\n
onLoad() {
\r\n
},
\r\n
onUnload() {
\r\n
},
\r\n
methods: {
\r\n
uploadFile: function () {
\r\n
uni.chooseImage({
\r\n
count: 1,
\r\n
success(res) : void {
\r\n
uni.showLoading({
\r\n
title: '上传中...'
\r\n
})
\r\n
const tempFilePath = res.tempFilePaths[0]
\r\n
uniCloud.uploadFile({
\r\n
filePath: tempFilePath,
\r\n
cloudPath: 'test.jpg'
\r\n
})
\r\n
.then(function (res) {
\r\n
uni.hideLoading()
\r\n
console.log(res)
\r\n
uni.showModal({
\r\n
content: '上传成功',
\r\n
showCancel: false
\r\n
});
\r\n
})
\r\n
.catch(function (err : any | null) {
\r\n
uni.hideLoading()
\r\n
const error = err as UniCloudError
\r\n
uni.showModal({
\r\n
content: '上传失败,' + error.errMsg,
\r\n
showCancel: false
\r\n
});
\r\n
})
\r\n
// .finally((_: number) : void => {
\r\n
// uni.hideLoading()
\r\n
// })
\r\n
},
\r\n
fail(err) : void {
\r\n
console.error('chooseImage fail: ', err)
\r\n
}
\r\n
})
\r\n
}
\r\n
}
\r\n
}
\r\n\n
```
\n\n
:::"
},
"databaseForJQL"
:{
"name"
:
"## databaseForJQL() @databaseforjql"
,
"description"
:
"获取数据库操作实例"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Database](#database-values) |
\n\n
#### Database 的属性值 @database-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| command | any | 是 | - | - |
\n
| Geo | any | 是 | - | - |
\n\n
#### Database 的方法 @database-values
\n\n
#### collection(args?) @collection
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - |
\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
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n
###### UniCloudDBFilter 的方法 @uniclouddbfilter-values
\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any | 否 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n\n
###### UniCloudDBGetResult 的属性值 @uniclouddbgetresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| data | Array
\\
<any
\\
> | 是 | - | tResult = { /** |
\n
| count | number | 否 | - | SONObject>; /** |
\n
| requestId | string | 否 | - | ber
\\
| null; / |
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n\n
###### UniCloudDBCountResult 的属性值 @uniclouddbcountresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| total | number | 是 | - | tResult = { /** |
\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
| Promise<[UniCloudDBUpdateResult](#uniclouddbupdateresult-values)> |
\n\n
###### UniCloudDBUpdateResult 的属性值 @uniclouddbupdateresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| updated | number | 是 | - | eResult = { /** |
\n
| requestId | string | 否 | - | ed: number; / |
\n\n\n\n
##### remove() @remove
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBRemoveResult](#uniclouddbremoveresult-values)> |
\n\n
###### UniCloudDBRemoveResult 的属性值 @uniclouddbremoveresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| deleted | number | 是 | - | eResult = { /** |
\n
| requestId | string | 否 | - | ed: number; / |
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n\n\n\n
##### where(condition) @where
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| condition | any | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### doc(docId) @doc
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| docId | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\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 | 否 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### groupBy(field) @groupby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### groupField(field) @groupfield
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### distinct(field) @distinct
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### geoNear(options) @geonear
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | any | 是 | - | |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### groupBy(field) @groupby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### groupField(field) @groupfield
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### distinct(field) @distinct
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| field | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### geoNear(options) @geonear
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| options | any | 是 | - | |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n\n\n
##### doc(docId) @doc
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| docId | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### aggregate() @aggregate
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### foreignKey(foreignKey) @foreignkey
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| foreignKey | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n\n\n
##### add(data) @add
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| data | any | 是 | - | |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBAddResult](#uniclouddbaddresult-values)> |
\n\n
###### UniCloudDBAddResult 的属性值 @uniclouddbaddresult-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| id | string | 是 | - | dResult = { /** |
\n
| requestId | string | 否 | - | string; / |
\n\n\n\n
##### get(arg?) @get
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| arg | any | 否 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n\n\n\n
##### count() @count
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n\n\n\n
##### getTemp() @gettemp
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n\n\n\n
##### field(filed) @field
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| filed | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### skip(num) @skip
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### limit(num) @limit
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| num | number | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n
##### orderBy(order) @orderby
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| order | string | 是 | - | - |
\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n\n\n\n
"
,
"compatibility"
:
"### databaseForJQL 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 阿里云 3.91,腾讯云 3.91 | x | - |
\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>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view class=
\"
page-scroll-view
\"
>
\r\n
<!-- #endif -->
\r\n
<view>
\r\n
<page-head :title=
\"
title
\"
></page-head>
\r\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@click=
\"
dbAdd
\"
>新增单条数据</button>
\r\n
<button type=
\"
primary
\"
@click=
\"
dbBatchAdd
\"
>新增多条数据</button>
\r\n
<button type=
\"
primary
\"
@click=
\"
dbUpdate
\"
>更新数据</button>
\r\n
<button type=
\"
primary
\"
@click=
\"
dbGet
\"
>where传字符串获取数据</button>
\r\n
<button type=
\"
primary
\"
@click=
\"
dbGetWithCommand
\"
>where传对象获取数据</button>
\r\n
<button type=
\"
primary
\"
@click=
\"
dbRemove
\"
>删除数据</button>
\r\n
<button type=
\"
primary
\"
@click=
\"
dbLookupInit
\"
>初始化联表查询数据</button>
\r\n
<button type=
\"
primary
\"
@click=
\"
dbLookup
\"
>联表查询</button>
\r\n
</view>
\r\n
</view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n\r\n\r\n
<style>
\r\n
</style>
\r\n\n
```
\n
>Script
\n
```uts
\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
title: 'ClientDB',
\r\n
addId: '',
\r\n
batchAddIds: [] as Array<string>,
\r\n
batchAddinserted: 0,
\r\n
updateUpdated: 0,
\r\n
getData: [] as Array<UTSJSONObject>,
\r\n
getWithCommandData: [] as Array<UTSJSONObject>,
\r\n
removeDeleted: 0,
\r\n
lookupData: [] as Array<UTSJSONObject>,
\r\n
isUniTest: false
\r\n
}
\r\n
},
\r\n
onLoad() {
\r\n
},
\r\n
onUnload() {
\r\n
if (this.isUniTest) {
\r\n
uni.hideToast()
\r\n
}
\r\n
},
\r\n
computed: {
\r\n
dataTag() : string {
\r\n
return this.isUniTest ? 'default-tag' + Date.now() : 'default-tag'
\r\n
}
\r\n
},
\r\n
methods: {
\r\n
notify(content : string, title : string) {
\r\n
if (!this.isUniTest) {
\r\n
uni.showModal({
\r\n
title,
\r\n
content,
\r\n
showCancel: false
\r\n
})
\r\n
} else {
\r\n
uni.showToast({
\r\n
title: content
\r\n
})
\r\n
console.log(title, content)
\r\n
}
\r\n
},
\r\n
async dbAdd() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
const db = uniCloud.databaseForJQL()
\r\n
await db.collection('type')
\r\n
.add({
\r\n
num: 1,
\r\n
tag: this.dataTag,
\r\n
date: new Date()
\r\n
})
\r\n
.then(res => {
\r\n
uni.hideLoading()
\r\n
console.log(res)
\r\n
this.addId = res.id
\r\n
this.notify(`新增成功,id: ${res.id}`, '提示')
\r\n
})
\r\n
.catch((err : any | null) => {
\r\n
uni.hideLoading()
\r\n
const error = err as UniCloudError
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
},
\r\n
async dbBatchAdd() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
const db = uniCloud.databaseForJQL()
\r\n
await db.collection('type')
\r\n
.add([{
\r\n
num: 2,
\r\n
tag: this.dataTag,
\r\n
}, {
\r\n
num: 3,
\r\n
tag: this.dataTag,
\r\n
}])
\r\n
.then((res) => {
\r\n
uni.hideLoading()
\r\n
console.log(res)
\r\n
console.log('JSON.stringify(res.inserted)', JSON.stringify(res.inserted))
\r\n
this.batchAddIds = res.ids
\r\n
this.batchAddinserted = res.inserted
\r\n
this.notify(`新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`, '提示')
\r\n
})
\r\n
.catch((err : any | null) => {
\r\n
uni.hideLoading()
\r\n
const error = err as UniCloudError
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
},
\r\n
async dbGet() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
const db = uniCloud.databaseForJQL()
\r\n
await db.collection('type')
\r\n
.where(
\r\n
`tag ==
\"
${this.dataTag}
\"
`
\r\n
)
\r\n
.field('num, tag')
\r\n
.orderBy('num desc')
\r\n
.skip(1)
\r\n
.limit(2)
\r\n
.get()
\r\n
.then(res => {
\r\n
uni.hideLoading()
\r\n
console.log(res)
\r\n
this.getData = res.data
\r\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\r\n
})
\r\n
.catch((err : any | null) => {
\r\n
uni.hideLoading()
\r\n
const error = err as UniCloudError
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
},
\r\n
async dbGetWithCommand() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
const db = uniCloud.databaseForJQL()
\r\n
await db.collection('type')
\r\n
.where({
\r\n
num: db.command.gt(1),
\r\n
tag: this.dataTag
\r\n
})
\r\n
.field('num, tag')
\r\n
.orderBy('num desc')
\r\n
.skip(1)
\r\n
.limit(2)
\r\n
.get()
\r\n
.then(res => {
\r\n
uni.hideLoading()
\r\n
console.log(res)
\r\n
this.getWithCommandData = res.data
\r\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\r\n
})
\r\n
.catch((err : any | null) => {
\r\n
uni.hideLoading()
\r\n
const error = err as UniCloudError
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
},
\r\n
async dbUpdate() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
const db = uniCloud.databaseForJQL()
\r\n
await db.collection('type')
\r\n
.where(
\r\n
`tag ==
\"
${this.dataTag}
\"
`
\r\n
)
\r\n
.update({
\r\n
num: 4
\r\n
})
\r\n
.then(res => {
\r\n
uni.hideLoading()
\r\n
console.log(res)
\r\n
this.updateUpdated = res.updated
\r\n
this.notify(`更新成功,更新了${res.updated}条数据`, '提示')
\r\n
})
\r\n
.catch((err : any | null) => {
\r\n
uni.hideLoading()
\r\n
const error = err as UniCloudError
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
},
\r\n
async dbRemove() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
const db = uniCloud.databaseForJQL()
\r\n
await db.collection('type')
\r\n
.where(
\r\n
`tag ==
\"
${this.dataTag}
\"
`
\r\n
)
\r\n
.remove()
\r\n
.then(res => {
\r\n
uni.hideLoading()
\r\n
console.log(res)
\r\n
this.removeDeleted = res.deleted
\r\n
this.notify(`删除成功,删掉了${res.deleted}条数据`, '提示')
\r\n
})
\r\n
.catch((err : any | null) => {
\r\n
uni.hideLoading()
\r\n
const error = err as UniCloudError
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
},
\r\n
async dbLookupInit() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
const db = uniCloud.databaseForJQL()
\r\n
await db.collection('local')
\r\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\r\n
.remove()
\r\n
.then(() : Promise<UniCloudDBRemoveResult> => {
\r\n
return db.collection('foreign')
\r\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\r\n
.remove()
\r\n
})
\r\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\r\n
return db.collection('local')
\r\n
.add([{
\r\n
id:
\"
local_1
\"
,
\r\n
name:
\"
local_1_name
\"
,
\r\n
tag: this.dataTag,
\r\n
foreign_id:
\"
foreign_1
\"\r\n
}, {
\r\n
id:
\"
local_2
\"
,
\r\n
name:
\"
local_2_name
\"
,
\r\n
tag: this.dataTag,
\r\n
foreign_id:
\"
foreign_2
\"\r\n
}])
\r\n
})
\r\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\r\n
return db.collection('foreign')
\r\n
.add([{
\r\n
id:
\"
foreign_1
\"
,
\r\n
name:
\"
foreign_1_name
\"
,
\r\n
tag: this.dataTag
\r\n
}, {
\r\n
id:
\"
foreign_2
\"
,
\r\n
name:
\"
foreign_2_name
\"
,
\r\n
tag: this.dataTag
\r\n
}])
\r\n
})
\r\n
.then((_) : void => {
\r\n
uni.hideLoading()
\r\n
this.notify('数据初始化成功', '提示')
\r\n
})
\r\n
.catch((err : any | null) => {
\r\n
uni.hideLoading()
\r\n
console.error(err)
\r\n
const error = err as UniCloudError
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
},
\r\n
async dbLookup() : Promise<void> {
\r\n
uni.showLoading({
\r\n
title: '加载中...'
\r\n
})
\r\n
const db = uniCloud.databaseForJQL()
\r\n
const local = db.collection('local')
\r\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\r\n
.getTemp()
\r\n
const foreign = db.collection('foreign')
\r\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\r\n
.getTemp()
\r\n
await db.collection(local, foreign)
\r\n
.get()
\r\n
.then(res => {
\r\n
uni.hideLoading()
\r\n
console.log(res)
\r\n
this.lookupData = res.data
\r\n
this.notify(`联表查询成功,取到了${res.data.length}条数据`, '提示')
\r\n
})
\r\n
.catch((err : any | null) => {
\r\n
uni.hideLoading()
\r\n
const error = err as UniCloudError
\r\n
this.notify(error.errMsg, '错误')
\r\n
})
\r\n
}
\r\n
}
\r\n
}
\r\n\n
```
\n\n
:::"
},
"onResponse"
:{
"name"
:
"## onResponse(callback) @onresponse"
,
"description"
:
"监听响应事件"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any | 是 | - | - |
\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 | x | - |
\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 | 是 | - | - |
\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 | x | - |
\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 | 是 | - | - |
\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 | x | - |
\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 | 是 | - | - |
\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 | x | - |
\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](#uniclouduserinfo-values) |
\n\n
#### UniCloudUserInfo 的属性值 @uniclouduserinfo-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 描述 |
\n
| :- | :- | :- | :- | :- |
\n
| uid | string | 否 | - | serInfo = { / |
\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 | x | - |
\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
docs/.vuepress/utils/vueJson.json
浏览文件 @
f99a1eeb
{
"template"
:{
"name"
:
"#### template"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| lang | Any | - | [lang](#template-lang-values) |
\n\n
##### lang @template-lang-values
\n\n
| 值名称 | 描述 |
\n
| :- | :- |
\n
| html | html |
\n
| pug | pug |
\n\n
"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### template 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | √ | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
""
},
"slot"
:{
"name"
:
"#### slot"
,
"description"
:
"> 组件类型:string
\n\n
\\
<slot> 元素作为组件模板之中的内容分发插槽。
\\
<slot> 元素自身将被替换。"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| name | string | - | 用于命名插槽。 |"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### slot 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | √ | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
"
\n
##### 参见
\n
- [Reference](https://v3.cn.vuejs.org/api/built-in-components.html#slot)
\n
"
},
"script"
:{
"name"
:
"#### script"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| setup | Any | - | - |
\n
| lang | Any | - | [lang](#script-lang-values) |
\n\n
##### lang @script-lang-values
\n\n
| 值名称 | 描述 |
\n
| :- | :- |
\n
| uts | uts |
\n\n\n
###### lang 兼容性
\n
| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| uts | 5.0 | 4.0 | x | 4.0 |
\n
"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"##### script 属性兼容性
\n
| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| setup | 5.0 | 4.0 | x | 4.0 |
\n\n
##### script 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | √ | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
""
},
"style"
:{
"name"
:
"#### style"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| lang | Any | - | [lang](#style-lang-values) |
\n
| scoped | Any | - | - |
\n
| module | Any | - | - |
\n\n
##### lang @style-lang-values
\n\n
| 值名称 | 描述 |
\n
| :- | :- |
\n
| scss | - |
\n
| less | - |
\n
| stylus | - |
\n\n
"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### style 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | √ | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
""
},
"keep-alive"
:{
"name"
:
"#### keep-alive"
,
"description"
:
"> 组件类型:string
\n\n
\\
<keep-alive> 包裹动态组件时,会缓存不活动的组件实例,而不是销毁它们。和
\\
<transition> 相似,
\\
<keep-alive> 是一个抽象组件:它自身不会渲染一个 DOM 元素,也不会出现在父组件链中。"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| include | string | - | 字符串或正则表达式。只有名称匹配的组件会被缓存。 |
\n
| exclude | string | - | 字符串或正则表达式。任何名称匹配的组件都不会被缓存。 |
\n
| max | string | - | 最多可以缓存多少组件实例。 |"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### keep-alive 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 4.0 | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
"
\n
##### 参见
\n
- [Reference](https://v3.cn.vuejs.org/api/built-in-components.html#keep-alive)
\n
"
},
"component"
:{
"name"
:
"#### component"
,
"description"
:
"> 组件类型:string
\n\n
渲染一个“元组件”为动态组件。依 is 的值,来决定哪个组件被渲染。"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| is | Any | - | - |
\n
| inline-template | Any | - | - |"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### component 兼容性
\n
| Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| 5.0 | 3.99 | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
"
\n
##### 参见
\n
- [Reference](https://v3.cn.vuejs.org/api/built-in-components.html#component)
\n
"
},
"application"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| createApp() | 5.0 | √ | x | 4.0 |
\n
| createSSRApp() | 5.0 | √ | x | 4.0 |
\n
| app.mount() | 5.0 | √ | x | 4.0 |
\n
| app.unmount() | 5.0 | √ | x | 4.0 |
\n
| app.component() | 5.0 | √ | x | 4.0 |
\n
| app.directive() | - | - | - | - |
\n
| app.use() | 5.0 | 3.99 | x | 4.0 |
\n
| app.mixin() | 5.0 | 3.99 | x | 4.0 |
\n
| app.provide() | 5.0 | 3.99 | x | 4.0 |
\n
| app.runWithContext() | - | - | - | - |
\n
| app.version | 5.0 | √ | x | 4.0 |
\n
| app.config | - | - | - | - |
\n
| app.config.errorHandler | - | - | - | - |
\n
| app.config.warnHandler | - | - | - | - |
\n
| app.config.performance | - | - | - | - |
\n
| app.config.compilerOptions | - | - | - | - |
\n
| app.config.globalProperties | 5.0 | 3.99 | x | 4.0 |
\n
| app.config.optionMergeStrategies | - | - | - | - |"
,
"example"
:
""
},
"general"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| version | 5.0 | √ | x | 4.0 |
\n
| nextTick() | 5.0 | √ | x | 4.0 |
\n
| defineComponent() | 5.0 | x | x | 4.0 |
\n
| defineAsyncComponent() | - | - | - | - |
\n
| defineCustomElement() | - | - | - | - |"
,
"example"
:
""
},
"reactivity_core"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| ref() | 5.0 | √ | x | 4.0 |
\n
| computed() | 5.0 | √ | x | 4.0 |
\n
| reactive() | 5.0 | √ | x | 4.0 |
\n
| readonly() | 5.0 | 4.0 | x | 4.0 |
\n
| watchEffect() | 5.0 | 4.0 | x | 4.0 |
\n
| watchPostEffect() | 5.0 | 4.0 | x | 4.0 |
\n
| watchSyncEffect() | 5.0 | 4.0 | x | 4.0 |
\n
| watch() | 5.0 | 4.0 | x | 4.0 |"
,
"example"
:
""
},
"reactivity_utilities"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| isRef() | 5.0 | 4.0 | x | 4.0 |
\n
| unref() | 5.0 | 4.0 | x | 4.0 |
\n
| isReactive() | 5.0 | 4.0 | x | 4.0 |
\n
| isReadonly() | 5.0 | 4.0 | x | 4.0 |
\n
| toRef() | 5.0 | 4.0 | x | 4.0 |
\n
| toValue() | 5.0 | 4.0 | x | x |
\n
| toRefs() | 5.0 | 4.0 | x | 4.0 |
\n
| isProxy() | 5.0 | 4.0 | x | 4.0 |"
,
"example"
:
""
},
"reactivity_advanced"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| shallowReactive() | 5.0 | 4.0 | x | 4.0 |
\n
| shallowRef() | 5.0 | 4.0 | x | 4.0 |
\n
| toRaw() | 5.0 | 4.0 | x | 4.0 |
\n
| triggerRef() | 5.0 | 4.0 | x | x |
\n
| customRef() | 5.0 | 4.0 | x | 4.0 |
\n
| shallowReadonly() | 5.0 | 4.0 | x | 4.0 |
\n
| markRaw() | - | - | - | - |
\n
| effectScope() | 5.0 | 4.0 | x | 4.0 |
\n
| getCurrentScope() | 5.0 | 4.0 | x | 4.0 |
\n
| onScopeDispose() | 5.0 | 4.0 | x | 4.0 |"
,
"example"
:
""
},
"composition_lifecycle"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| onMounted() | 5.0 | 4.0 | x | 4.0 |
\n
| onUpdated() | 5.0 | 4.0 | x | 4.0 |
\n
| onUnmounted() | 5.0 | 4.0 | x | 4.0 |
\n
| onBeforeMount() | 5.0 | 4.0 | x | 4.0 |
\n
| onBeforeUpdate() | 5.0 | 4.0 | x | 4.0 |
\n
| onBeforeUnmount() | 5.0 | 4.0 | x | 4.0 |
\n
| onErrorCaptured() | - | - | - | - |
\n
| onRenderTracked() | - | - | - | - |
\n
| onRenderTriggered() | - | - | - | - |
\n
| onActivated() | 5.0 | x | x | 4.0 |
\n
| onDeactivated() | 5.0 | x | x | 4.0 |
\n
| onServerPrefetch() | - | - | - | - |"
,
"example"
:
""
},
"composition_injection"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| provide() | 5.0 | 4.0 | x | 4.0 |
\n
| inject() | 5.0 | 4.0 | x | 4.0 |
\n
| hasInjectionContext() | 5.0 | 4.0 | x | x |"
,
"example"
:
""
},
"options_state"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| data | 5.0 | √ | x | 4.0 |
\n
| props | 5.0 | √ | x | 4.0 |
\n
| computed | 5.0 | √ | x | 4.0 |
\n
| methods | 5.0 | √ | x | 4.0 |
\n
| watch | 5.0 | √ | x | 4.0 |
\n
| emits | 5.0 | √ | x | 4.0 |
\n
| expose | - | - | - | - |"
,
"example"
:
"#### 状态选项 示例
\n
- [选项式 API 示例](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/state)"
},
"options_rendering"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| template | - | - | - | - |
\n
| render | 5.0 | √ | x | 4.0 |
\n
| compilerOptions | - | - | - | - |
\n
| slots | 5.0 | √ | x | 4.0 |"
,
"example"
:
"#### 渲染选项 示例
\n
- [指令示例](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/rendering)"
},
"options_lifecycle"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| beforeCreate | 5.0 | √ | x | 4.0 |
\n
| created | 5.0 | √ | x | 4.0 |
\n
| beforeMount | 5.0 | √ | x | 4.0 |
\n
| mounted | 5.0 | √ | x | 4.0 |
\n
| beforeUpdate | 5.0 | √ | x | 4.0 |
\n
| updated | 5.0 | √ | x | 4.0 |
\n
| beforeUnmount | 5.0 | √ | x | 4.0 |
\n
| unmounted | 5.0 | √ | x | 4.0 |
\n
| errorCaptured | - | - | - | - |
\n
| renderTracked | - | - | - | - |
\n
| renderTriggered | - | - | - | - |
\n
| activated | 5.0 | 4.0 | x | 4.0 |
\n
| deactivated | 5.0 | 4.0 | x | 4.0 |
\n
| serverPrefetch | - | - | - | - |"
,
"example"
:
"#### 页面生命周期示例 示例
\n
> [hello uvue](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/lifecycle/page/page.uvue)
\n
```html
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view style=
\"
flex: 1
\"
>
\n
<!-- #endif -->
\n
<view class=
\"
page container
\"
>
\n
<text>page lifecycle</text>
\n
<button class=
\"
uni-common-mt
\"
@click=
\"
scrollToBottom
\"
>scrollToBottom</button>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n
<script lang=
\"
uts
\"
>
\n
import { state, setLifeCycleNum } from '@/store/index.uts'
\n\n
export default {
\n
data() {
\n
return {
\n
isScrolled: false,
\n
}
\n
},
\n
onLoad(_ : OnLoadOptions) {
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum + 100)
\n
},
\n
onShow() {
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum + 10)
\n
},
\n
onReady() {
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum + 10)
\n
},
\n
onPullDownRefresh() {
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum + 10)
\n
},
\n
onPageScroll(_) {
\n
// 自动化测试
\n
this.isScrolled = true
\n
},
\n
onReachBottom() {
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum + 10)
\n
},
\n
onBackPress(_ : OnBackPressOptions) : boolean | null {
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum - 10)
\n
return null
\n
},
\n
onHide() {
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum - 10)
\n
},
\n
onUnload() {
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum - 100)
\n
},
\n
onResize(_){
\n
// 自动化测试
\n
setLifeCycleNum(state.lifeCycleNum + 10)
\n
},
\n
methods: {
\n
// 自动化测试
\n
getLifeCycleNum() : number {
\n
return state.lifeCycleNum
\n
},
\n
// 自动化测试
\n
setLifeCycleNum(num : number) {
\n
setLifeCycleNum(num)
\n
},
\n
// 自动化测试
\n
pullDownRefresh() {
\n
uni.startPullDownRefresh({
\n
success() {
\n
setTimeout(() => {
\n
uni.stopPullDownRefresh()
\n
}, 1000)
\n
},
\n
})
\n
},
\n
scrollToBottom() {
\n
uni.pageScrollTo({
\n
scrollTop: 2000,
\n
})
\n
},
\n
},
\n
}
\n
</script>
\n\n
<style>
\n
.container {
\n
height: 1200px;
\n
}
\n
</style>
\n\n
```
\n
#### 组件生命周期示例 示例
\n
> [hello uvue](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/lifecycle/component/component.uvue)
\n
```html
\n
<template>
\n
<view class=
\"
page
\"
>
\n
<text class=
\"
uni-common-mb
\"
>component lifecycle</text>
\n
<component-lifecycle class=
\"
component-lifecycle
\"
/>
\n
</view>
\n
</template>
\n\n
<script>
\n
import ComponentLifecycle from '@/components/OptionsAPILifecycle.uvue'
\n
import { state } from '@/store/index.uts'
\n
export default {
\n
components: { ComponentLifecycle },
\n
methods: {
\n
// 自动化测试
\n
getLifeCycleNum(): number {
\n
return state.lifeCycleNum
\n
},
\n
},
\n
}
\n
</script>
\n\n
```"
},
"options_composition"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| provide | 5.0 | 3.99 | x | 4.0 |
\n
| inject | 5.0 | 3.99 | x | 4.0 |
\n
| mixins | 5.0 | 3.99 | x | 4.0 |
\n
| extends | - | - | - | - |"
,
"example"
:
""
},
"options_misc"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| name | 5.0 | √ | x | 4.0 |
\n
| inheritAttrs | 5.0 | √ | x | 4.0 |
\n
| components | 5.0 | √ | x | 4.0 |
\n
| directives | - | - | - | - |"
,
"example"
:
""
},
"component_instance"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| $data | 5.0 | √ | x | 4.0 |
\n
| $props | 5.0 | √ | x | 4.0 |
\n
| $el | 5.0 | √ | x | 4.0 |
\n
| $options | 5.0 | √ | x | 4.0 |
\n
| $parent | 5.0 | √ | x | 4.0 |
\n
| $root | 5.0 | √ | x | 4.0 |
\n
| $slots | 5.0 | √ | x | 4.0 |
\n
| $refs | 5.0 | √ | x | 4.0 |
\n
| $attrs | 5.0 | √ | x | 4.0 |
\n
| $watch() | 5.0 | √ | x | 4.0 |
\n
| $emit | 5.0 | √ | x | 4.0 |
\n
| $forceUpdate | 5.0 | √ | x | 4.0 |
\n
| $nextTick | 5.0 | √ | x | 4.0 |
\n
| $callMethod | 5.0 | √ | x | 4.0 |"
,
"example"
:
"#### 组件实例 示例
\n
- [组件实例示例](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/component-instance)"
},
"directives"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| v-text | 5.0 | √ | x | 4.0 |
\n
| v-html | 5.0 | 3.99 | x | 4.0 |
\n
| v-show | 5.0 | √ | x | 4.0 |
\n
| v-if | 5.0 | √ | x | 4.0 |
\n
| v-else | 5.0 | √ | x | 4.0 |
\n
| v-else-if | 5.0 | √ | x | 4.0 |
\n
| v-for | 5.0 | √ | x | 4.0 |
\n
| v-on | 5.0 | √ | x | 4.0 |
\n
| v-bind | 5.0 | √ | x | 4.0 |
\n
| v-model | 5.0 | √ | x | 4.0 |
\n
| v-slot | 5.0 | √ | x | 4.0 |
\n
| v-pre | 5.0 | 3.99 | x | 4.0 |
\n
| v-once | 5.0 | 3.99 | x | 4.0 |
\n
| v-memo | 5.0 | 3.99 | x | 4.0 |
\n
| v-cloak | 5.0 | x | x | 4.0 |"
,
"example"
:
"#### 指令 示例
\n
- [指令示例](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/directive)"
},
"special_attributes"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| key | 5.0 | √ | x | 4.0 |
\n
| ref | 5.0 | √ | x | 4.0 |
\n
| is | 5.0 | 3.99 | x | 4.0 |"
,
"example"
:
""
},
"render_function"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| h() | 5.0 | 3.99 | x | 4.0 |
\n
| mergeProps() | 5.0 | 4.0 | x | 4.0 |
\n
| cloneVNode() | 5.0 | 4.0 | x | 4.0 |
\n
| isVNode() | 5.0 | √ | x | 4.0 |
\n
| resolveComponent() | 5.0 | √ | x | 4.0 |
\n
| resolveDirective() | - | - | - | - |
\n
| withDirectives() | 5.0 | √ | x | 4.0 |
\n
| withModifiers() | 5.0 | √ | x | 4.0 |"
,
"example"
:
""
},
"single_file_component_script"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| defineProps() | 5.0 | 4.0 | x | 4.0 |
\n
| defineEmits() | 5.0 | 4.0 | x | 4.0 |
\n
| defineModel() | 5.0 | 4.0 | x | x |
\n
| defineExpose() | 5.0 | 4.0 | x | 4.0 |
\n
| defineOptions() | 5.0 | 4.0 | x | x |
\n
| defineSlots() | 5.0 | 4.0 | x | 4.0 |
\n
| useSlots() | 5.0 | 4.0 | x | 4.0 |
\n
| useAttrs() | 5.0 | 4.0 | x | 4.0 |"
,
"example"
:
""
}}
\ No newline at end of file
{
"template"
:{
"name"
:
"#### template"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| lang | Any | - | [lang](#template-lang-values) |
\n\n
##### lang @template-lang-values
\n\n
| 值名称 | 描述 |
\n
| :- | :- |
\n
| html | html |
\n
| pug | pug |
\n\n
"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### template 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| √ | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
""
},
"slot"
:{
"name"
:
"#### slot"
,
"description"
:
"> 组件类型:string
\n\n
\\
<slot> 元素作为组件模板之中的内容分发插槽。
\\
<slot> 元素自身将被替换。"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| name | string | - | 用于命名插槽。 |"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### slot 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| √ | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
"
\n
##### 参见
\n
- [Reference](https://v3.cn.vuejs.org/api/built-in-components.html#slot)
\n
"
},
"script"
:{
"name"
:
"#### script"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| setup | Any | - | - |
\n
| lang | Any | - | [lang](#script-lang-values) |
\n\n
##### lang @script-lang-values
\n\n
| 值名称 | 描述 |
\n
| :- | :- |
\n
| uts | uts |
\n\n\n
###### lang 兼容性
\n
| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| uts | 4.0 | x | 4.0 |
\n
"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"##### script 属性兼容性
\n
| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| setup | 4.0 | x | 4.0 |
\n\n
##### script 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| √ | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
""
},
"style"
:{
"name"
:
"#### style"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| lang | Any | - | [lang](#style-lang-values) |
\n
| scoped | Any | - | - |
\n
| module | Any | - | - |
\n\n
##### lang @style-lang-values
\n\n
| 值名称 | 描述 |
\n
| :- | :- |
\n
| scss | - |
\n
| less | - |
\n
| stylus | - |
\n\n
"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### style 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| √ | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
""
},
"keep-alive"
:{
"name"
:
"#### keep-alive"
,
"description"
:
"> 组件类型:string
\n\n
\\
<keep-alive> 包裹动态组件时,会缓存不活动的组件实例,而不是销毁它们。和
\\
<transition> 相似,
\\
<keep-alive> 是一个抽象组件:它自身不会渲染一个 DOM 元素,也不会出现在父组件链中。"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| include | string | - | 字符串或正则表达式。只有名称匹配的组件会被缓存。 |
\n
| exclude | string | - | 字符串或正则表达式。任何名称匹配的组件都不会被缓存。 |
\n
| max | string | - | 最多可以缓存多少组件实例。 |"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### keep-alive 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 4.0 | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
"
\n
##### 参见
\n
- [Reference](https://v3.cn.vuejs.org/api/built-in-components.html#keep-alive)
\n
"
},
"component"
:{
"name"
:
"#### component"
,
"description"
:
"> 组件类型:string
\n\n
渲染一个“元组件”为动态组件。依 is 的值,来决定哪个组件被渲染。"
,
"attrubute"
:
"##### 属性
\n
| 名称 | 类型 | 默认值 | 描述 |
\n
| :- | :- | :- | :- |
\n
| is | Any | - | - |
\n
| inline-template | Any | - | - |"
,
"event"
:
""
,
"example"
:
""
,
"compatibility"
:
"
\n
##### component 兼容性
\n
| Android | iOS | web |
\n
| :- | :- | :- |
\n
| 3.99 | x | 4.0 |
\n
"
,
"children"
:
""
,
"reference"
:
"
\n
##### 参见
\n
- [Reference](https://v3.cn.vuejs.org/api/built-in-components.html#component)
\n
"
},
"application"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| createApp() | 5.0 | √ | x | 4.0 |
\n
| createSSRApp() | 5.0 | √ | x | 4.0 |
\n
| app.mount() | 5.0 | √ | x | 4.0 |
\n
| app.unmount() | 5.0 | √ | x | 4.0 |
\n
| app.component() | 5.0 | √ | x | 4.0 |
\n
| app.directive() | - | - | - | - |
\n
| app.use() | 5.0 | 3.99 | x | 4.0 |
\n
| app.mixin() | 5.0 | 3.99 | x | 4.0 |
\n
| app.provide() | 5.0 | 3.99 | x | 4.0 |
\n
| app.runWithContext() | - | - | - | - |
\n
| app.version | 5.0 | √ | x | 4.0 |
\n
| app.config | - | - | - | - |
\n
| app.config.errorHandler | - | - | - | - |
\n
| app.config.warnHandler | - | - | - | - |
\n
| app.config.performance | - | - | - | - |
\n
| app.config.compilerOptions | - | - | - | - |
\n
| app.config.globalProperties | 5.0 | 3.99 | x | 4.0 |
\n
| app.config.optionMergeStrategies | - | - | - | - |"
,
"example"
:
""
},
"general"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| version | 5.0 | √ | x | 4.0 |
\n
| nextTick() | 5.0 | √ | x | 4.0 |
\n
| defineComponent() | 5.0 | x | x | 4.0 |
\n
| defineAsyncComponent() | - | - | - | - |
\n
| defineCustomElement() | - | - | - | - |"
,
"example"
:
""
},
"reactivity_core"
:{
"compatibility"
:
"| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| ref() | √ | x | 4.0 |
\n
| computed() | √ | x | 4.0 |
\n
| reactive() | √ | x | 4.0 |
\n
| readonly() | 4.0 | x | 4.0 |
\n
| watchEffect() | 4.0 | x | 4.0 |
\n
| watchPostEffect() | 4.0 | x | 4.0 |
\n
| watchSyncEffect() | 4.0 | x | 4.0 |
\n
| watch() | 4.0 | x | 4.0 |"
,
"example"
:
""
},
"reactivity_utilities"
:{
"compatibility"
:
"| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| isRef() | 4.0 | x | 4.0 |
\n
| unref() | 4.0 | x | 4.0 |
\n
| toRef() | 4.0 | x | 4.0 |
\n
| toValue() | 4.0 | x | x |
\n
| toRefs() | 4.0 | x | 4.0 |
\n
| isProxy() | 4.0 | x | 4.0 |
\n
| isReactive() | 4.0 | x | 4.0 |
\n
| isReadonly() | 4.0 | x | 4.0 |"
,
"example"
:
""
},
"reactivity_advanced"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| shallowRef() | 5.0 | 4.0 | x | 4.0 |
\n
| triggerRef() | 5.0 | 4.0 | x | x |
\n
| customRef() | 5.0 | 4.0 | x | 4.0 |
\n
| shallowReactive() | 5.0 | 4.0 | x | 4.0 |
\n
| shallowReadonly() | 5.0 | 4.0 | x | 4.0 |
\n
| toRaw() | 5.0 | 4.0 | x | 4.0 |
\n
| markRaw() | - | - | - | - |
\n
| effectScope() | 5.0 | 4.0 | x | 4.0 |
\n
| getCurrentScope() | 5.0 | 4.0 | x | 4.0 |
\n
| onScopeDispose() | 5.0 | 4.0 | x | 4.0 |"
,
"example"
:
""
},
"composition_lifecycle"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| onMounted() | 5.0 | 4.0 | x | 4.0 |
\n
| onUpdated() | 5.0 | 4.0 | x | 4.0 |
\n
| onUnmounted() | 5.0 | 4.0 | x | 4.0 |
\n
| onBeforeMount() | 5.0 | 4.0 | x | 4.0 |
\n
| onBeforeUpdate() | 5.0 | 4.0 | x | 4.0 |
\n
| onBeforeUnmount() | 5.0 | 4.0 | x | 4.0 |
\n
| onErrorCaptured() | - | - | - | - |
\n
| onRenderTracked() | - | - | - | - |
\n
| onRenderTriggered() | - | - | - | - |
\n
| onActivated() | 5.0 | x | x | 4.0 |
\n
| onDeactivated() | 5.0 | x | x | 4.0 |
\n
| onServerPrefetch() | - | - | - | - |"
,
"example"
:
""
},
"composition_injection"
:{
"compatibility"
:
"| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| provide() | 4.0 | x | 4.0 |
\n
| inject() | 4.0 | x | 4.0 |
\n
| hasInjectionContext() | 4.0 | x | x |"
,
"example"
:
""
},
"options_state"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| data | 5.0 | √ | x | 4.0 |
\n
| props | 5.0 | √ | x | 4.0 |
\n
| computed | 5.0 | √ | x | 4.0 |
\n
| methods | 5.0 | √ | x | 4.0 |
\n
| watch | 5.0 | √ | x | 4.0 |
\n
| emits | 5.0 | √ | x | 4.0 |
\n
| expose | - | - | - | - |"
,
"example"
:
"#### 状态选项 示例
\n
- [选项式 API 示例](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/state)"
},
"options_rendering"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| template | - | - | - | - |
\n
| render | 5.0 | √ | x | 4.0 |
\n
| compilerOptions | - | - | - | - |
\n
| slots | 5.0 | √ | x | 4.0 |"
,
"example"
:
"#### 渲染选项 示例
\n
- [指令示例](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/rendering)"
},
"options_lifecycle"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| beforeCreate | 5.0 | √ | x | 4.0 |
\n
| created | 5.0 | √ | x | 4.0 |
\n
| beforeMount | 5.0 | √ | x | 4.0 |
\n
| mounted | 5.0 | √ | x | 4.0 |
\n
| beforeUpdate | 5.0 | √ | x | 4.0 |
\n
| updated | 5.0 | √ | x | 4.0 |
\n
| beforeUnmount | 5.0 | √ | x | 4.0 |
\n
| unmounted | 5.0 | √ | x | 4.0 |
\n
| errorCaptured | - | - | - | - |
\n
| renderTracked | - | - | - | - |
\n
| renderTriggered | - | - | - | - |
\n
| activated | 5.0 | 4.0 | x | 4.0 |
\n
| deactivated | 5.0 | 4.0 | x | 4.0 |
\n
| serverPrefetch | - | - | - | - |"
,
"example"
:
"#### 页面生命周期示例 示例
\n
> [hello uvue](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/lifecycle/page/page.uvue)
\n
```html
\n
<template>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view style=
\"
flex: 1
\"
>
\r\n
<!-- #endif -->
\r\n
<view class=
\"
page container
\"
>
\r\n
<text>page lifecycle</text>
\r\n
<button class=
\"
uni-common-mt
\"
@click=
\"
scrollToBottom
\"
>scrollToBottom</button>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n
<script lang=
\"
uts
\"
>
\r\n
import { state, setLifeCycleNum } from '@/store/index.uts'
\r\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
isScrolled: false,
\r\n
}
\r\n
},
\r\n
onLoad(_ : OnLoadOptions) {
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum + 100)
\r\n
},
\r\n
onShow() {
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum + 10)
\r\n
},
\r\n
onReady() {
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum + 10)
\r\n
},
\r\n
onPullDownRefresh() {
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum + 10)
\r\n
},
\r\n
onPageScroll(_) {
\r\n
// 自动化测试
\r\n
this.isScrolled = true
\r\n
},
\r\n
onReachBottom() {
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum + 10)
\r\n
},
\r\n
onBackPress(_ : OnBackPressOptions) : boolean | null {
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum - 10)
\r\n
return null
\r\n
},
\r\n
onHide() {
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum - 10)
\r\n
},
\r\n
onUnload() {
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum - 100)
\r\n
},
\r\n
onResize(_){
\r\n
// 自动化测试
\r\n
setLifeCycleNum(state.lifeCycleNum + 10)
\r\n
},
\r\n
methods: {
\r\n
// 自动化测试
\r\n
getLifeCycleNum() : number {
\r\n
return state.lifeCycleNum
\r\n
},
\r\n
// 自动化测试
\r\n
setLifeCycleNum(num : number) {
\r\n
setLifeCycleNum(num)
\r\n
},
\r\n
// 自动化测试
\r\n
pullDownRefresh() {
\r\n
uni.startPullDownRefresh({
\r\n
success() {
\r\n
setTimeout(() => {
\r\n
uni.stopPullDownRefresh()
\r\n
}, 1000)
\r\n
},
\r\n
})
\r\n
},
\r\n
scrollToBottom() {
\r\n
uni.pageScrollTo({
\r\n
scrollTop: 2000,
\r\n
})
\r\n
},
\r\n
},
\r\n
}
\r\n
</script>
\r\n\r\n
<style>
\r\n
.container {
\r\n
height: 1200px;
\r\n
}
\r\n
</style>
\r\n\n
```
\n
#### 组件生命周期示例 示例
\n
> [hello uvue](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/lifecycle/component/component.uvue)
\n
```html
\n
<template>
\r\n
<view class=
\"
page
\"
>
\r\n
<text class=
\"
uni-common-mb
\"
>component lifecycle</text>
\r\n
<component-lifecycle class=
\"
component-lifecycle
\"
/>
\r\n
</view>
\r\n
</template>
\r\n\r\n
<script>
\r\n
import ComponentLifecycle from '@/components/OptionsAPILifecycle.uvue'
\r\n
import { state } from '@/store/index.uts'
\r\n
export default {
\r\n
components: { ComponentLifecycle },
\r\n
methods: {
\r\n
// 自动化测试
\r\n
getLifeCycleNum(): number {
\r\n
return state.lifeCycleNum
\r\n
},
\r\n
},
\r\n
}
\r\n
</script>
\r\n\n
```"
},
"options_composition"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| provide | 5.0 | 3.99 | x | 4.0 |
\n
| inject | 5.0 | 3.99 | x | 4.0 |
\n
| mixins | 5.0 | 3.99 | x | 4.0 |
\n
| extends | - | - | - | - |"
,
"example"
:
""
},
"options_misc"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| name | 5.0 | √ | x | 4.0 |
\n
| inheritAttrs | 5.0 | √ | x | 4.0 |
\n
| components | 5.0 | √ | x | 4.0 |
\n
| directives | - | - | - | - |"
,
"example"
:
""
},
"component_instance"
:{
"compatibility"
:
"| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| $data | √ | x | 4.0 |
\n
| $props | √ | x | 4.0 |
\n
| $el | √ | x | 4.0 |
\n
| $options | √ | x | 4.0 |
\n
| $parent | √ | x | 4.0 |
\n
| $root | √ | x | 4.0 |
\n
| $slots | √ | x | 4.0 |
\n
| $refs | √ | x | 4.0 |
\n
| $attrs | √ | x | 4.0 |
\n
| $watch() | √ | x | 4.0 |
\n
| $emit | √ | x | 4.0 |
\n
| $forceUpdate | √ | x | 4.0 |
\n
| $nextTick | √ | x | 4.0 |
\n
| $callMethod | √ | x | 4.0 |"
,
"example"
:
"#### 组件实例 示例
\n
- [组件实例示例](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/component-instance)"
},
"directives"
:{
"compatibility"
:
"| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| v-text | √ | x | 4.0 |
\n
| v-html | 3.99 | x | 4.0 |
\n
| v-show | √ | x | 4.0 |
\n
| v-if | √ | x | 4.0 |
\n
| v-else | √ | x | 4.0 |
\n
| v-else-if | √ | x | 4.0 |
\n
| v-for | √ | x | 4.0 |
\n
| v-on | √ | x | 4.0 |
\n
| v-bind | √ | x | 4.0 |
\n
| v-model | √ | x | 4.0 |
\n
| v-slot | √ | x | 4.0 |
\n
| v-pre | 3.99 | x | 4.0 |
\n
| v-once | 3.99 | x | 4.0 |
\n
| v-memo | 3.99 | x | 4.0 |
\n
| v-cloak | x | x | 4.0 |"
,
"example"
:
"#### 指令 示例
\n
- [指令示例](https://gitcode.net/dcloud/hello-uvue/-/tree/master//pages/directive)"
},
"special_attributes"
:{
"compatibility"
:
"| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| key | √ | x | 4.0 |
\n
| ref | √ | x | 4.0 |
\n
| is | 3.99 | x | 4.0 |"
,
"example"
:
""
},
"render_function"
:{
"compatibility"
:
"| | Android 系统版本 | Android | iOS | web |
\n
| :- | :- | :- | :- | :- |
\n
| h() | 5.0 | 3.99 | x | 4.0 |
\n
| mergeProps() | 5.0 | 4.0 | x | 4.0 |
\n
| cloneVNode() | 5.0 | 4.0 | x | 4.0 |
\n
| isVNode() | 5.0 | √ | x | 4.0 |
\n
| resolveComponent() | 5.0 | √ | x | 4.0 |
\n
| resolveDirective() | - | - | - | - |
\n
| withDirectives() | 5.0 | √ | x | 4.0 |
\n
| withModifiers() | 5.0 | √ | x | 4.0 |"
,
"example"
:
""
},
"single_file_component_script"
:{
"compatibility"
:
"| | Android | iOS | web |
\n
| :- | :- | :- | :- |
\n
| defineProps() | 4.0 | x | 4.0 |
\n
| defineEmits() | 4.0 | x | 4.0 |
\n
| defineModel() | 4.0 | x | x |
\n
| defineExpose() | 4.0 | x | 4.0 |
\n
| defineOptions() | 4.0 | x | x |
\n
| defineSlots() | 4.0 | x | 4.0 |
\n
| useSlots() | 4.0 | x | 4.0 |
\n
| useAttrs() | 4.0 | x | 4.0 |"
,
"example"
:
""
}}
\ No newline at end of file
docs/css/README.md
浏览文件 @
f99a1eeb
...
...
@@ -291,11 +291,11 @@ rpx和百分比,比px更容易产生浮点数,所以如果px能满足需求
<!-- CSSJSON.color_values.compatibility -->
## css方法
## css方法
@css-function
目前仅支持url()、rgb()、rgba()、var()。
##
#
CSS 变量(4.0+)@variable
## CSS 变量(4.0+)@variable
uni-app x 4.0起 提供内置 CSS 变量。之前版本如有获取状态栏高度等需求可使用
[
uni.getWindowInfo()
](
../api/get-window-info.md
)
方式获取。
...
...
@@ -349,24 +349,8 @@ uni-app x 4.0起 提供内置 CSS 变量。之前版本如有获取状态栏高
```
## At-rules
|类别 |App支持情况 |备注 |
|:-: |:-: |:-: |
|@import |√ | |
|@font-face |√ | |
|@charset |× | |
|@color-profile |× | |
|@container |× | |
|@counter-style |× | |
|@documentNon-standardDeprecated|× | |
|@font-feature-values |× | |
|@font-palette-values |× | |
|@keyframes |× | |
|@layer |× | |
|@media |× | |
|@namespace |× | |
|@page |× | |
|@property |× | |
|@supports |× | |
<!-- CSSJSON.at_rules_values.compatibility -->
@font-face自定义字体示例:
```
html
...
...
docs/uts/_sidebar.md
浏览文件 @
f99a1eeb
...
...
@@ -24,6 +24,7 @@
*
[
Promise
](
buildin-object-api/promise.md
)
*
[
RegExp
](
buildin-object-api/regexp.md
)
*
[
Error
](
buildin-object-api/error.md
)
*
[
Timers
](
buildin-object-api/timers.md
)
*
[
Console
](
buildin-object-api/console.md
)
*
[
全局
](
buildin-object-api/global.md
)
*
平台专用对象和 API
...
...
docs/uts/buildin-object-api/timers.md
0 → 100644
浏览文件 @
f99a1eeb
# Timers
## 实例方法
### setInterval(handler, timeout?, arguments)
<!-- UTSJSON.Timers.setInterval.description -->
<!-- UTSJSON.Timers.setInterval.param -->
<!-- UTSJSON.Timers.setInterval.returnValue -->
<!-- UTSJSON.Timers.setInterval.compatibility -->
<!-- UTSJSON.Timers.setInterval.tutorial -->
### setTimeout(handler, timeout?, arguments)
<!-- UTSJSON.Timers.setTimeout.description -->
<!-- UTSJSON.Timers.setTimeout.param -->
<!-- UTSJSON.Timers.setTimeout.returnValue -->
<!-- UTSJSON.Timers.setTimeout.compatibility -->
<!-- UTSJSON.Timers.setTimeout.tutorial -->
### clearInterval(id)
<!-- UTSJSON.Timers.clearInterval.description -->
<!-- UTSJSON.Timers.clearInterval.param -->
<!-- UTSJSON.Timers.clearInterval.returnValue -->
<!-- UTSJSON.Timers.clearInterval.compatibility -->
<!-- UTSJSON.Timers.clearInterval.tutorial -->
### clearTimeout(id)
<!-- UTSJSON.Timers.clearTimeout.description -->
<!-- UTSJSON.Timers.clearTimeout.param -->
<!-- UTSJSON.Timers.clearTimeout.returnValue -->
<!-- UTSJSON.Timers.clearTimeout.compatibility -->
<!-- UTSJSON.Timers.clearTimeout.tutorial -->
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录