diff --git a/docs/.vuepress/utils/utsApiJson.json b/docs/.vuepress/utils/utsApiJson.json index d35f509a6a598679da958b4f4c0096e45bf40a20..fcc9824d45aa0d0920865388af8f0945ed4758ca 100644 --- a/docs/.vuepress/utils/utsApiJson.json +++ b/docs/.vuepress/utils/utsApiJson.json @@ -1 +1 @@ -{"getApp":{"name":"## getApp() @getapp","description":"\n`getApp()` 函数用于获取当前应用实例,可通过应用实例调用 App.uvue methods 中定义的方法。","param":"","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| any | \n","compatibility":"","tutorial":"\n### 参见\n[getApp](https://uniapp.dcloud.net.cn/tutorial/page.html#getapp)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.global.get-app)\n"},"get-app":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/get-app/get-app.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-app/get-app\n>Template\n```vue\n\n\n\n\n\n\n```\n>Script\n```uts\n\n import { state, setLifeCycleNum } from '@/store/index.uts'\n\n type MyGlobalData = {\n str : string,\n num : number,\n bool : boolean,\n obj : UTSJSONObject,\n null : string | null,\n arr : number[],\n mySet : string[],\n myMap : UTSJSONObject,\n func : () => string\n }\n\n export default {\n data() {\n return {\n originGlobalData: {\n str: '',\n num: 0,\n bool: false,\n obj: {\n str: '',\n num: 0,\n bool: false\n } as UTSJSONObject,\n null: null,\n arr: [] as number[],\n mySet: [] as string[],\n myMap: {},\n func: () : string => ''\n } as MyGlobalData,\n originGlobalDataFuncRes: '',\n newGlobalData: {\n str: '',\n num: 0,\n bool: false,\n obj: {\n str: '',\n num: 0,\n bool: false\n } as UTSJSONObject,\n null: null,\n arr: [] as number[],\n mySet: [] as string[],\n myMap: {},\n func: () : string => ''\n } as MyGlobalData,\n newGlobalDataFuncRes: '',\n lifeCycleNum: 0,\n }\n },\n onReady() {\n this.lifeCycleNum = state.lifeCycleNum\n },\n methods: {\n getGlobalData() {\n const app = getApp()\n\n this.originGlobalData.str = app.globalData.str\n this.originGlobalData.num = app.globalData.num\n this.originGlobalData.bool = app.globalData.bool\n this.originGlobalData.obj = app.globalData.obj\n this.originGlobalData.null = app.globalData.null\n this.originGlobalData.arr = app.globalData.arr\n app.globalData.mySet.forEach((value : string) => {\n this.originGlobalData.mySet.push(value)\n })\n app.globalData.myMap.forEach((value : any, key : string) => {\n this.originGlobalData.myMap[key] = value\n })\n this.originGlobalData.func = app.globalData.func\n this.originGlobalDataFuncRes = this.originGlobalData.func()\n },\n setGlobalData() {\n const app = getApp()\n\n app.globalData.str = 'new globalData str'\n app.globalData.num = 100\n app.globalData.bool = true\n app.globalData.obj = {\n str: 'new globalData obj str',\n num: 200,\n bool: true\n }\n app.globalData.null = 'not null'\n app.globalData.arr = [1, 2, 3]\n app.globalData.mySet = new Set(['a', 'b', 'c'])\n app.globalData.myMap = new Map([\n ['a', 1],\n ['b', 2],\n ['c', 3]\n ])\n app.globalData.func = () : string => {\n return 'new globalData func'\n }\n\n this.newGlobalData.str = app.globalData.str\n this.newGlobalData.num = app.globalData.num\n this.newGlobalData.bool = app.globalData.bool\n this.newGlobalData.obj = app.globalData.obj\n this.newGlobalData.null = app.globalData.null\n this.newGlobalData.arr = app.globalData.arr\n app.globalData.mySet.forEach((value : string) => {\n this.newGlobalData.mySet.push(value)\n })\n app.globalData.myMap.forEach((value : any, key : string) => {\n this.newGlobalData.myMap[key] = value\n })\n this.newGlobalData.func = app.globalData.func\n this.newGlobalDataFuncRes = this.newGlobalData.func()\n },\n _increasetLifeCycleNum: function () {\n const app = getApp()\n app.increasetLifeCycleNum()\n this.lifeCycleNum = state.lifeCycleNum\n },\n // 自动化测试\n setLifeCycleNum(num : number) {\n setLifeCycleNum(num)\n }\n },\n }\n\n```\n\n:::"},"getCurrentPages":{"name":"## getCurrentPages() @getcurrentpages","description":"\n`getCurrentPages()` 函数用于获取当前页面栈的实例,以数组形式按栈的顺序给出,数组中的元素为页面实例,第一个元素为首页,最后一个元素为当前页面。","param":"","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| Array\\<[Page](#page-values)\\> | \n\n#### Page 的属性值 @page-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| route | string | 是 | - | 页面的路由地址 |\n| options | Map\\ | 是 | - | 页面的路由参数信息 |\n","compatibility":"","tutorial":"\n### 参见\n[getCurrentPages](https://uniapp.dcloud.net.cn/tutorial/page.html#getcurrentpages)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.global.get-current-pages)\n"},"get-current-pages":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/get-current-pages/get-current-pages.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-current-pages/get-current-pages\n>Template\n```vue\n\n\n\n\n```\n>Script\n```uts\n\n class Page {\n constructor(public route : string) {\n }\n }\n\n export default {\n data() {\n return {\n checked: false,\n pages: [] as Page[],\n }\n },\n methods: {\n _getCurrentPages: function () {\n this.pages.length = 0\n const pages = getCurrentPages()\n this.pages.push(new Page(pages[0].route))\n if (this.pages[0].route.includes('/tabBar/')) {\n this.checked = true\n }\n for (let i = 1; i < pages.length; i++) {\n this.pages.push(new Page(pages[i].route))\n if (pages[i].route.includes('/tabBar/')) {\n this.checked = false\n }\n }\n },\n },\n }\n\n```\n\n:::"},"$on":{"name":"## uni.$on(eventName, callback) @$on","description":"\n监听自定义事件。事件可以由 uni.$emit 触发。回调函数会接收 uni.$emit 传递的参数。\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| eventName | string | 是 | - | - |\n| callback | () => void | 是 | - | - |","returnValue":"","compatibility":"### $on 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[$on](https://doc.dcloud.net.cn/uni-app-x/api/event-bus.html#on)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.event-bus.$on)\n"},"$once":{"name":"## uni.$once(eventName, callback) @$once","description":"\n监听一个自定义事件。事件只触发一次,在第一次触发之后移除事件监听器。\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| eventName | string | 是 | - | - |\n| callback | () => void | 是 | - | - |","returnValue":"","compatibility":"### $once 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[$once](https://doc.dcloud.net.cn/uni-app-x/api/event-bus.html#once)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.event-bus.$once)\n"},"$off":{"name":"## uni.$off(eventName, callback) @$off","description":"\n移除自定义事件监听器。如果没有指定事件名,则移除所有事件监听器。如果提供事件名,则移除该事件的所有监听器。如果提供了事件名和回调,则只移除这个回调的监听器。\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| eventName | string | 是 | - | - |\n| callback | () => void | 是 | - | - |","returnValue":"","compatibility":"### $off 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[$off](https://doc.dcloud.net.cn/uni-app-x/api/event-bus.html#off)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.event-bus.$off)\n"},"$emit":{"name":"## uni.$emit(eventName, args?) @$emit","description":"\n触发自定义事件,附加的参数会传递给事件监听器。\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| eventName | string | 是 | - | - |\n| args | any \\| null | 否 | - | |","returnValue":"","compatibility":"### $emit 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[$emit](https://doc.dcloud.net.cn/uni-app-x/api/event-bus.html#emit)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.event-bus.$emit)\n"},"event-bus":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/event-bus/event-bus.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/event-bus/event-bus\n>Template\n```vue\n\r\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n log: [] as string[],\r\n }\r\n },\r\n methods: {\r\n fn(res : string) {\r\n this.log.push(res)\r\n },\r\n on() {\r\n uni.$on('test', this.fn)\r\n },\r\n once() {\r\n uni.$once('test', this.fn)\r\n },\r\n off() {\r\n uni.$off('test', this.fn)\r\n },\r\n emit() {\r\n uni.$emit('test', 'msg:' + Date.now())\r\n },\r\n clear() {\r\n this.log.length = 0\r\n },\r\n },\r\n }\r\n\n```\n\n:::"},"addInterceptor":{"name":"## uni.addInterceptor(name, interceptor) @addinterceptor","description":"\n添加拦截器","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| name | string | 是 | - | 需要拦截的 API 名称 |\n| interceptor | [Interceptor](#interceptor-values) | 是 | - | 拦截器 |\n#### Interceptor 的属性值 @interceptor-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| invoke | Function \\| null | 否 | - | |\n| returnValue | Function \\| null | 否 | - | |\n| success | Function \\| null | 否 | - | |\n| fail | Function \\| null | 否 | - | |\n| complete | Function \\| null | 否 | - | |\n","returnValue":"","compatibility":"### addInterceptor 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.97 | x | 4.0 |\n","tutorial":"\n### 参见\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.interceptor.addInterceptor)\n"},"removeInterceptor":{"name":"## uni.removeInterceptor(name, interceptor?) @removeinterceptor","description":"\n删除拦截器","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| name | string | 是 | - | 需要删除拦截器的 API 名称 |\n| interceptor | interface \\| null | 否 | - | |","returnValue":"","compatibility":"### removeInterceptor 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.97 | x | 4.0 |\n","tutorial":"\n### 参见\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.interceptor.removeInterceptor)\n"},"interceptor":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/interceptor/interceptor.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/interceptor/interceptor\n>Template\n```vue\n\r\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n const interceptor = {\r\n invoke: function (options : NavigateToOptions) {\r\n console.log('拦截 navigateTo 接口传入参数为:', options)\r\n const url = './page2'\r\n uni.showToast({\r\n title: `重定向到页面:${url}`\r\n })\r\n options.url = url\r\n },\r\n success: function (res : NavigateBackSuccess) {\r\n console.log('拦截 navigateTo 接口 success 返回参数为:', res)\r\n },\r\n fail: function (err : NavigateToFail) {\r\n console.log('拦截 navigateTo 接口 fail 返回参数为:', err)\r\n },\r\n complete: function (res : NavigateToComplete) {\r\n console.log('拦截 navigateTo 接口 complete 返回参数为:', res)\r\n }\r\n } as Interceptor\r\n export default {\r\n data() {\r\n return {\r\n msg: \"会跳转到测试页面1\"\r\n }\r\n },\r\n beforeUnmount() {\r\n // 移除 navigateTo 所有拦截器\r\n uni.removeInterceptor('navigateTo')\r\n },\r\n methods: {\r\n addInterceptor() {\r\n uni.addInterceptor('navigateTo', interceptor)\r\n uni.showToast({\r\n title: '页面跳转已拦截'\r\n })\r\n this.msg = \",路由被劫持到测试页面2\"\r\n },\r\n removeInterceptor() {\r\n uni.removeInterceptor('navigateTo', interceptor)\r\n uni.showToast({\r\n title: '拦截器已移除'\r\n })\r\n this.msg = \"会跳转到测试页面1\"\r\n },\r\n navigateTo() {\r\n uni.navigateTo({\r\n url: './page1',\r\n success(res) {\r\n console.log('res:', res)\r\n },\r\n fail(err) {\r\n console.error('err:', err)\r\n },\r\n complete(res) {\r\n console.log('res:', res)\r\n }\r\n })\r\n }\r\n }\r\n }\r\n\n```\n\n:::"},"getLaunchOptionsSync":{"name":"## uni.getLaunchOptionsSync() @getlaunchoptionssync","description":"\n获取本次启动时的参数。返回值与App.onLaunch的回调参数一致\n","param":"","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [OnLaunchOptions](#onlaunchoptions-values) | \n\n#### OnLaunchOptions 的属性值 @onlaunchoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| path | string | 是 | - | - |\n","compatibility":"### getLaunchOptionsSync 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[getLaunchOptionsSync](https://doc.dcloud.net.cn/uni-app-x/api/get-launch-options-sync.html)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.get-launch-options-sync)\n"},"get-launch-options-sync":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/get-launch-options-sync/get-launch-options-sync.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-launch-options-sync/get-launch-options-sync\n>Template\n```vue\n\n\n\n\n```\n>Script\n```uts\n\nexport default {\n data() {\n return {\n checked: false,\n homePagePath: 'pages/tabBar/component',\n launchOptionsPath: '',\n }\n },\n methods: {\n getLaunchOptionsSync() {\n const launchOptions = uni.getLaunchOptionsSync()\n this.launchOptionsPath = launchOptions.path\n\n if (launchOptions.path == this.homePagePath) {\n this.checked = true\n }\n },\n },\n}\n\n```\n\n:::"},"exit":{"name":"## uni.exit(options?) @exit","description":"\n退出当前应用","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | interface \\| null | 否 | - | uni.exit参数定义 |","returnValue":"","compatibility":"### exit 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9.0 | x | - |\n","tutorial":"\n### 参见\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.exit)\n","example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/exit/exit.uvue) \n ```vue\n\n\n\n\n\n```"},"env":{"name":"## env","description":"","param":"### env 的属性值 @env-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| USER_DATA_PATH | string | 是 | - | 应用专属存储空间的外置存储空间根目录下的files目录 |\n| CACHE_PATH | string | 是 | - | 应用专属存储空间的外置存储空间根目录下的cache目录 |\n| SANDBOX_PATH | string | 是 | - | 应用专属存储空间的外置存储空间根目录(caches/files) |\n","compatibility":"#### env 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| USER_DATA_PATH | 3.99 | x | - |\n| CACHE_PATH | 3.99 | x | - |\n| SANDBOX_PATH | 3.99 | x | - |\n","returnValue":"","tutorial":"\n### 参见\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.base.env)\n"},"navigateTo":{"name":"## uni.navigateTo(options) @navigateto","description":"\n保留当前页面,跳转到应用内的某个页面\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [NavigateToOptions](#navigatetooptions-values) | 是 | - | - |\n#### NavigateToOptions 的属性值 @navigatetooptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string (string.PageURIString) | 是 | - | 需要跳转的应用内非 tabBar 的页面的路径 , 路径后可以带参数 |\n| animationType | string \\| null | 否 | - | |\n| animationDuration | number \\| null | 否 | - | |\n| events | any \\| null | 否 | - | |\n| success | Function \\| null | 否 | - | |\n| fail | Function \\| null | 否 | - | |\n| complete | Function \\| null | 否 | - | |\n\n##### NavigateToOptions 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| url | √ | x | 4.0 |\n| animationType | x | x | 4.0 |\n| animationDuration | x | x | 4.0 |\n| events | x | x | 4.0 |\n| success | √ | x | 4.0 |\n| fail | √ | x | 4.0 |\n| complete | √ | x | 4.0 |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### navigateTo 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| √ | x | 4.0 |\n","tutorial":"\n### 参见\n[navigateTo](http://uniapp.dcloud.io/api/router?id=navigateto)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.navigator.navigateTo)\n"},"reLaunch":{"name":"## uni.reLaunch(options) @relaunch","description":"\n关闭所有页面,打开到应用内的某个页面\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [ReLaunchOptions](#relaunchoptions-values) | 是 | - | - |\n#### ReLaunchOptions 的属性值 @relaunchoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string (string.PageURIString) | 是 | - | 需要跳转的应用内非 tabBar 的页面的路径 , 路径后可以带参数 |\n| success | Function \\| null | 否 | - | |\n| fail | Function \\| null | 否 | - | |\n| complete | Function \\| null | 否 | - | |\n\n##### ReLaunchOptions 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| url | √ | x | 4.0 |\n| success | √ | x | 4.0 |\n| fail | √ | x | 4.0 |\n| complete | √ | x | 4.0 |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### reLaunch 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| √ | x | 4.0 |\n","tutorial":"\n### 参见\n[reLaunch](http://uniapp.dcloud.io/api/router?id=relaunch)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.navigator.reLaunch)\n"},"navigateBack":{"name":"## uni.navigateBack(options?) @navigateback","description":"\n关闭当前页面,返回上一页面或多级页面\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | interface \\| null | 否 | - | |","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### navigateBack 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| √ | x | 4.0 |\n","tutorial":"\n### 参见\n[navigateBack](http://uniapp.dcloud.io/api/router?id=navigateback)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.navigator.navigateBack)\n"},"redirectTo":{"name":"## uni.redirectTo(options) @redirectto","description":"\n关闭当前页面,跳转到应用内的某个页面\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [RedirectToOptions](#redirecttooptions-values) | 是 | - | - |\n#### RedirectToOptions 的属性值 @redirecttooptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string (string.PageURIString) | 是 | - | 需要跳转的应用内非 tabBar 的页面的路径 , 路径后可以带参数 |\n| success | Function \\| null | 否 | - | |\n| fail | Function \\| null | 否 | - | |\n| complete | Function \\| null | 否 | - | |\n\n##### RedirectToOptions 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| url | √ | x | 4.0 |\n| success | √ | x | 4.0 |\n| fail | √ | x | 4.0 |\n| complete | √ | x | 4.0 |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### redirectTo 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| √ | x | 4.0 |\n","tutorial":"\n### 参见\n[redirectTo](http://uniapp.dcloud.io/api/router?id=redirectto)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.navigator.redirectTo)\n"},"switchTab":{"name":"## uni.switchTab(options) @switchtab","description":"\n跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SwitchTabOptions](#switchtaboptions-values) | 是 | - | - |\n#### SwitchTabOptions 的属性值 @switchtaboptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string (string.PageURIString) | 是 | - | 需要跳转的 tabBar 页面的路径,路径后不能带参数 |\n| success | Function \\| null | 否 | - | |\n| fail | Function \\| null | 否 | - | |\n| complete | Function \\| null | 否 | - | |\n\n##### SwitchTabOptions 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| url | √ | x | 4.0 |\n| success | √ | x | 4.0 |\n| fail | √ | x | 4.0 |\n| complete | √ | x | 4.0 |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### switchTab 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| √ | x | 4.0 |\n","tutorial":"\n### 参见\n[switchTab](http://uniapp.dcloud.io/api/router?id=switchtab)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.navigator.switchTab)\n"},"navigator":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/navigator/navigator.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/navigator/navigator\n>Template\n```vue\n\r\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n import { state, setLifeCycleNum } from '@/store/index.uts'\r\n\r\n export default {\r\n data() {\r\n return {\r\n onLoadTime: 0,\r\n onShowTime: 0,\r\n onReadyTime: 0,\r\n onHideTime: 0,\r\n }\r\n },\r\n onLoad() {\r\n this.onLoadTime = Date.now()\r\n console.log('onLoad', this.onLoadTime)\r\n },\r\n onShow() {\r\n this.onShowTime = Date.now()\r\n console.log('onShow', this.onShowTime)\r\n },\r\n onReady() {\r\n this.onReadyTime = Date.now()\r\n console.log('onReady', this.onReadyTime)\r\n },\r\n onHide() {\r\n this.onHideTime = Date.now()\r\n console.log('onHide', this.onHideTime)\r\n },\r\n onBackPress(options : OnBackPressOptions) : boolean | null {\r\n console.log('onBackPress', Date.now())\r\n console.log('onBackPress from', options.from)\r\n return null\r\n },\r\n onUnload() {\r\n console.log('onUnload', Date.now())\r\n },\r\n methods: {\r\n reLaunch() {\r\n uni.reLaunch({\r\n url: '/pages/tabBar/component',\r\n success(result) {\r\n console.log('reLaunch success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail(error) {\r\n console.log('reLaunch fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete(result) {\r\n console.log('reLaunch complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n navigateTo() {\r\n uni.navigateTo({\r\n url: '/pages/API/navigator/new-page/new-page-1?data=Hello',\r\n success(result) {\r\n console.log('navigateTo success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail(error) {\r\n console.log('navigateTo fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete(result) {\r\n console.log('navigateTo complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n navigateToErrorPage() {\r\n uni.navigateTo({\r\n url: '/pages/error-page/error-page',\r\n success(result) {\r\n console.log('navigateTo success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n fail(error) {\r\n console.log('navigateTo fail', error.errMsg)\r\n uni.showToast({\r\n title: error.errMsg,\r\n icon: 'none',\r\n })\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n complete(result) {\r\n console.log('navigateTo complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n navigateToDebounce() {\r\n uni.navigateTo({\r\n url: '/pages/API/navigator/new-page/new-page-1?data=debounce',\r\n success(result) {\r\n console.log('navigateTo success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail(error) {\r\n console.log('navigateTo fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete(result) {\r\n console.log('navigateTo complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n uni.navigateTo({\r\n url: '/pages/API/navigator/new-page/new-page-1?data=debounce',\r\n success(result) {\r\n console.log('navigateTo success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n fail(error) {\r\n console.log('navigateTo fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n complete(result) {\r\n console.log('navigateTo complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n // 自动化测试\r\n navigateToRelativePath1() {\r\n uni.navigateTo({\r\n url: 'new-page/new-page-1?data=new-page/new-page-1',\r\n success() {\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail() {\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete() {\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n // 自动化测试\r\n navigateToRelativePath2() {\r\n uni.navigateTo({\r\n url: './new-page/new-page-1?data=./new-page/new-page-1',\r\n success() {\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail() {\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete() {\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n // 自动化测试\r\n navigateToRelativePath3() {\r\n uni.navigateTo({\r\n url: '../navigator/new-page/new-page-1?data=../navigator/new-page/new-page-1',\r\n success() {\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail() {\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete() {\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n navigateBack() {\r\n uni.navigateBack({\r\n success(result) {\r\n console.log('navigateBack success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail(error) {\r\n console.log('navigateBack fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete(result) {\r\n console.log('navigateBack complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n navigateBackWithDelta1() {\r\n uni.navigateTo({\r\n url: '/pages/API/navigator/new-page/new-page-1',\r\n success() {\r\n uni.navigateBack({\r\n delta: 1,\r\n success(result) {\r\n console.log('navigateBack success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail(error) {\r\n console.log('navigateBack fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete(result) {\r\n console.log('navigateBack complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n })\r\n },\r\n navigateBackWithDelta100() {\r\n uni.navigateTo({\r\n url: '/pages/API/navigator/new-page/new-page-1',\r\n success() {\r\n uni.navigateBack({\r\n delta: 100,\r\n success(result) {\r\n console.log('navigateBack success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail(error) {\r\n console.log('navigateBack fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete(result) {\r\n console.log('navigateBack complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n })\r\n },\r\n redirectTo() {\r\n uni.redirectTo({\r\n url: '/pages/API/navigator/new-page/new-page-1?data=Hello',\r\n success(result) {\r\n console.log('redirectTo success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail(error) {\r\n console.log('redirectTo fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete(result) {\r\n console.log('redirectTo complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\r\n switchTab() {\r\n uni.switchTab({\r\n url: '/pages/tabBar/template',\r\n success(result) {\r\n console.log('switchTab success', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n fail(error) {\r\n console.log('switchTab fail', error.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum - 1)\r\n },\r\n complete(result) {\r\n console.log('switchTab complete', result.errMsg)\r\n // 自动化测试\r\n setLifeCycleNum(state.lifeCycleNum + 1)\r\n },\r\n })\r\n },\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 }\r\n\n```\n\n:::"},"setNavigationBarColor":{"name":"## uni.setNavigationBarColor(options) @setnavigationbarcolor","description":"\n设置导航条、状态栏颜色\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SetNavigationBarColorOptions](#setnavigationbarcoloroptions-values) | 是 | - | - |\n#### SetNavigationBarColorOptions 的属性值 @setnavigationbarcoloroptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| frontColor | \"#ffffff\" \\| \"#000000\" | 是 | - | 前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000 |\n| backgroundColor | string | 是 | - | 背景颜色值,有效值为十六进制颜色 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (error: [SetNavigationBarColorError](#setnavigationbarcolorerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (res: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetNavigationBarColorError 的属性值 @setnavigationbarcolorerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | number | 是 | - | - |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| errMsg | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetNavigationBarColorOptions 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| frontColor | √ | x | 4.0 |\n| backgroundColor | √ | x | 4.0 |\n| success | √ | x | 4.0 |\n| fail | √ | x | 4.0 |\n| complete | √ | x | 4.0 |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### setNavigationBarColor 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| √ | x | 4.0 |\n","tutorial":"\n### 参见\n[setNavigationBarColor](https://doc.dcloud.net.cn/uni-app-x/api/set-navigation-bar-color.html)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-navigation-bar-color)\n"},"set-navigation-bar-color":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/set-navigation-bar-color/set-navigation-bar-color\n>Template\n```vue\n\n\n\n\n```\n>Script\n```uts\n\n import { state, setLifeCycleNum } from '@/store/index.uts'\n\n export default {\n methods: {\n setNavigationBarColor1() {\n uni.setNavigationBarColor({\n frontColor: '#ffffff',\n backgroundColor: '#00ff00',\n success: () => {\n console.log('setNavigationBarColor success')\n this.setLifeCycleNum(state.lifeCycleNum + 1)\n },\n fail: () => {\n console.log('setNavigationBarColor fail')\n this.setLifeCycleNum(state.lifeCycleNum - 1)\n },\n complete: () => {\n console.log('setNavigationBarColor complete')\n this.setLifeCycleNum(state.lifeCycleNum + 1)\n }\n })\n },\n setNavigationBarColor2() {\n uni.setNavigationBarColor({\n frontColor: '#000000',\n backgroundColor: '#ff0000',\n success: () => {\n console.log('setNavigationBarColor success')\n this.setLifeCycleNum(state.lifeCycleNum + 1)\n },\n fail: () => {\n console.log('setNavigationBarColor fail')\n this.setLifeCycleNum(state.lifeCycleNum - 1)\n },\n complete: () => {\n console.log('setNavigationBarColor complete')\n this.setLifeCycleNum(state.lifeCycleNum + 1)\n }\n })\n },\n // 自动化测试\n getLifeCycleNum() : number {\n return state.lifeCycleNum\n },\n // 自动化测试\n setLifeCycleNum(num : number) {\n setLifeCycleNum(num)\n },\n goCustomNavigation() {\n uni.navigateTo({\n url: '/pages/template/navbar-lite/navbar-lite'\n })\n }\n },\n }\n\n```\n\n:::"},"setNavigationBarTitle":{"name":"## uni.setNavigationBarTitle(options) @setnavigationbartitle","description":"\n动态设置当前页面的标题\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SetNavigationBarTitleOptions](#setnavigationbartitleoptions-values) | 是 | - | - |\n#### SetNavigationBarTitleOptions 的属性值 @setnavigationbartitleoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| title | string | 是 | - | 页面标题 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (error: [SetNavigationBarTitleError](#setnavigationbartitleerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (res: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetNavigationBarTitleError 的属性值 @setnavigationbartitleerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | number | 是 | - | - |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| errMsg | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetNavigationBarTitleOptions 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| title | 3.97 | x | 4.0 |\n| success | 3.97 | x | 4.0 |\n| fail | 3.97 | x | 4.0 |\n| complete | 3.97 | x | 4.0 |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### setNavigationBarTitle 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.97 | x | 4.0 |\n","tutorial":"\n### 参见\n[setNavigationBarTitle](https://doc.dcloud.net.cn/uni-app-x/api/set-navigation-bar-title.html)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-navigation-bar-title)\n"},"set-navigation-bar-title":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/set-navigation-bar-title/set-navigation-bar-title\n>Template\n```vue\n\n\n\n\n```\n>Script\n```uts\n\n import { state, setLifeCycleNum } from '@/store/index.uts'\n\n export default {\n data() {\n return {\n newTitle: 'new title',\n longTitle: 'long title long title long title long title long title long title long title long title long title long title'\n }\n },\n methods: {\n setNavigationBarNewTitle() {\n uni.setNavigationBarTitle({\n title: this.newTitle,\n success: () => {\n console.log('setNavigationBarTitle success')\n this.setLifeCycleNum(state.lifeCycleNum + 1)\n },\n fail: () => {\n console.log('setNavigationBarTitle fail')\n this.setLifeCycleNum(state.lifeCycleNum - 1)\n },\n complete: () => {\n console.log('setNavigationBarTitle complete')\n this.setLifeCycleNum(state.lifeCycleNum + 1)\n }\n })\n },\n setNavigationBarLongTitle() {\n uni.setNavigationBarTitle({\n title: this.longTitle,\n success() {\n console.log('setNavigationBarTitle success')\n },\n fail() {\n console.log('setNavigationBarTitle fail')\n },\n complete() {\n console.log('setNavigationBarTitle complete')\n }\n })\n },\n // 自动化测试\n getLifeCycleNum() : number {\n return state.lifeCycleNum\n },\n // 自动化测试\n setLifeCycleNum(num : number) {\n setLifeCycleNum(num)\n }\n },\n }\n\n```\n\n:::"},"showTabBar":{"name":"## uni.showTabBar(options?) @showtabbar","description":"\n显示 tabBar\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | interface \\| null | 否 | - | |","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### showTabBar 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[showTabBar](https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#showtabbar)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-tabbar.showTabBar)\n"},"hideTabBar":{"name":"## uni.hideTabBar(options?) @hidetabbar","description":"\n隐藏 tabBar\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | interface \\| null | 否 | - | |","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### hideTabBar 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[hideTabBar](https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#hidetabbar)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-tabbar.hideTabBar)\n"},"showTabBarRedDot":{"name":"## uni.showTabBarRedDot(options) @showtabbarreddot","description":"\n显示 tabBar 某一项的右上角的红点\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [ShowTabBarRedDotOptions](#showtabbarreddotoptions-values) | 是 | - | - |\n#### ShowTabBarRedDotOptions 的属性值 @showtabbarreddotoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| index | number | 是 | - | tabBar的哪一项,从左边算起,索引从0开始 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (result: [SetTabBarError](#settabbarerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (result: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetTabBarError 的属性值 @settabbarerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | 100 \\| 200 | 是 | - | 错误码
- 100: TabBar 不存在
- 200: 参数错误 |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| errMsg | string | 是 | - | 统一错误描述信息 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| name | string | 是 | - | - |\n| message | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### showTabBarRedDot 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[showTabBarRedDot](https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#showtabbarreddot)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-tabbar.showTabBarRedDot)\n"},"hideTabBarRedDot":{"name":"## uni.hideTabBarRedDot(options) @hidetabbarreddot","description":"\n隐藏 tabBar 某一项的右上角的红点\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [HideTabBarRedDotOptions](#hidetabbarreddotoptions-values) | 是 | - | - |\n#### HideTabBarRedDotOptions 的属性值 @hidetabbarreddotoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| index | number | 是 | - | tabBar的哪一项,从左边算起,索引从0开始 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (result: [SetTabBarError](#settabbarerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (result: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetTabBarError 的属性值 @settabbarerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | 100 \\| 200 | 是 | - | 错误码
- 100: TabBar 不存在
- 200: 参数错误 |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| errMsg | string | 是 | - | 统一错误描述信息 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| name | string | 是 | - | - |\n| message | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### hideTabBarRedDot 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[hideTabBarRedDot](https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#hidetabbarreddot)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-tabbar.hideTabBarRedDot)\n"},"setTabBarBadge":{"name":"## uni.setTabBarBadge(options) @settabbarbadge","description":"\n为 tabBar 某一项的右上角添加文本\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SetTabBarBadgeOptions](#settabbarbadgeoptions-values) | 是 | - | - |\n#### SetTabBarBadgeOptions 的属性值 @settabbarbadgeoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| index | number | 是 | - | tabBar的哪一项,从左边算起,索引从0开始 |\n| text | string | 是 | - | 显示的文本,不超过 3 个半角字符 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (result: [SetTabBarError](#settabbarerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (result: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetTabBarError 的属性值 @settabbarerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | 100 \\| 200 | 是 | - | 错误码
- 100: TabBar 不存在
- 200: 参数错误 |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| errMsg | string | 是 | - | 统一错误描述信息 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| name | string | 是 | - | - |\n| message | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### setTabBarBadge 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[setTabBarBadge](https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#settabbarbadge)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-tabbar.setTabBarBadge)\n"},"removeTabBarBadge":{"name":"## uni.removeTabBarBadge(options) @removetabbarbadge","description":"\n移除 tabBar 某一项右上角的文本\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [RemoveTabBarBadgeOptions](#removetabbarbadgeoptions-values) | 是 | - | - |\n#### RemoveTabBarBadgeOptions 的属性值 @removetabbarbadgeoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| index | number | 是 | - | tabBar的哪一项,从左边算起,索引从0开始 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (result: [SetTabBarError](#settabbarerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (result: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetTabBarError 的属性值 @settabbarerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | 100 \\| 200 | 是 | - | 错误码
- 100: TabBar 不存在
- 200: 参数错误 |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| errMsg | string | 是 | - | 统一错误描述信息 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| name | string | 是 | - | - |\n| message | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### removeTabBarBadge 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[removeTabBarBadge](https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#removetabbarbadge)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-tabbar.removeTabBarBadge)\n"},"setTabBarStyle":{"name":"## uni.setTabBarStyle(options) @settabbarstyle","description":"\n动态设置 tabBar 的整体样式\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SetTabBarStyleOptions](#settabbarstyleoptions-values) | 是 | - | - |\n#### SetTabBarStyleOptions 的属性值 @settabbarstyleoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| color | string (string.ColorString) | 否 | - | tab 上的文字默认颜色 |\n| selectedColor | string (string.ColorString) | 否 | - | tab 上的文字选中时的颜色 |\n| backgroundColor | string (string.ColorString) | 否 | - | tab 的背景色 |\n| backgroundImage | string | 否 | - | 图片背景 |\n| backgroundRepeat | \"repeat\" \\| \"repeat-x\" \\| \"repeat-y\" \\| \"no-repeat\" | 否 | - | 背景图平铺方式
- repeat: 背景图片在垂直方向和水平方向平铺
- repeat-x: 背景图片在水平方向平铺,垂直方向拉伸
- repeat-y: 背景图片在垂直方向平铺,水平方向拉伸
- no-repeat: 背景图片在垂直方向和水平方向都拉伸 |\n| borderStyle | string | 否 | - | tabbar上边框的颜色 |\n| midButton | [MidButtonOptions](#midbuttonoptions-values) | 否 | - | tabbar 中间按钮 仅在 list 项为偶数时有效 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (result: [SetTabBarError](#settabbarerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (result: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### MidButtonOptions 的属性值 @midbuttonoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| width | string | 否 | - | 中间按钮的宽度,tabBar 其它项为减去此宽度后平分,默认值为与其它项平分宽度。默认 80px |\n| height | string | 否 | - | 中间按钮的高度,可以大于 tabBar 高度,达到中间凸起的效果。默认 50px |\n| text | string | 否 | - | 中间按钮的文字 |\n| iconPath | string | 否 | - | 中间按钮的图片路径 |\n| iconWidth | string | 否 | - | 图片宽度(高度等比例缩放)。默认 24px |\n| backgroundImage | string | 否 | - | 中间按钮的背景图片路径 |\n| iconfont | [MidButtonIconFont](#midbuttoniconfont-values) | 否 | - | 字体图标,优先级高于 iconPath |\n\n###### MidButtonIconFont 的属性值 @midbuttoniconfont-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| text | string | 否 | - | 字库 Unicode 码 |\n| selectedText | string | 否 | - | 选中后字库 Unicode 码 |\n| fontSize | string | 否 | - | 字体图标字号(px) |\n| color | string | 否 | - | 字体图标颜色 |\n| selectedColor | string | 否 | - | 字体图标选中颜色 |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetTabBarError 的属性值 @settabbarerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | 100 \\| 200 | 是 | - | 错误码
- 100: TabBar 不存在
- 200: 参数错误 |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| errMsg | string | 是 | - | 统一错误描述信息 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| name | string | 是 | - | - |\n| message | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### setTabBarStyle 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[setTabBarStyle](https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#settabbarstyle)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-tabbar.setTabBarStyle)\n"},"setTabBarItem":{"name":"## uni.setTabBarItem(options) @settabbaritem","description":"\n动态设置 tabBar 某一项的内容\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SetTabBarItemOptions](#settabbaritemoptions-values) | 是 | - | - |\n#### SetTabBarItemOptions 的属性值 @settabbaritemoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| index | number | 是 | - | tabBar 的哪一项,从左边算起,索引从0开始 |\n| text | string | 否 | - | tab 上按钮文字 |\n| iconPath | string | 否 | - | 图片路径 |\n| selectedIconPath | string | 否 | - | 选中时的图片路径 |\n| pagePath | string | 否 | - | 页面绝对路径 |\n| iconfont | [SetTabBarItemIconFontOptions](#settabbaritemiconfontoptions-values) | 否 | - | 字体图标,优先级高于 iconPath |\n| visible | boolean | 否 | - | tab 是否显示 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (result: [SetTabBarError](#settabbarerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (result: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### SetTabBarItemIconFontOptions 的属性值 @settabbaritemiconfontoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| text | string | 是 | - | 字库 Unicode 码 |\n| selectedText | string | 是 | - | 选中后字库 Unicode 码 |\n| fontSize | string | 否 | - | 字体图标字号(px) |\n| color | string | 否 | - | 字体图标颜色 |\n| selectedColor | string | 否 | - | 字体图标选中颜色 |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### SetTabBarError 的属性值 @settabbarerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | 100 \\| 200 | 是 | - | 错误码
- 100: TabBar 不存在
- 200: 参数错误 |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| errMsg | string | 是 | - | 统一错误描述信息 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| name | string | 是 | - | - |\n| message | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### setTabBarItem 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[setTabBarItem](https://doc.dcloud.net.cn/uni-app-x/api/set-tabbar.html#settabbaritem)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.set-tabbar.setTabBarItem)\n"},"startPullDownRefresh":{"name":"## uni.startPullDownRefresh(options?) @startpulldownrefresh","description":"\n开始下拉刷新\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | interface \\| null | 否 | - | |","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### startPullDownRefresh 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[startPullDownRefresh](https://uniapp.dcloud.io/uni-app-x/api/pull-down-refresh.html#startpulldownrefresh)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.pull-down-refresh.startPullDownRefresh)\n"},"stopPullDownRefresh":{"name":"## uni.stopPullDownRefresh() @stoppulldownrefresh","description":"\n停止当前页面下拉刷新\n","param":"","returnValue":"","compatibility":"### stopPullDownRefresh 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[stopPullDownRefresh](https://doc.dcloud.net.cn/uni-app-x/api/pull-down-refresh.html#stoppulldownrefresh)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.pull-down-refresh.stopPullDownRefresh)\n"},"pull-down-refresh":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/pull-down-refresh/pull-down-refresh.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/pull-down-refresh/pull-down-refresh\n>Template\n```vue\n\n\n\n\n\n```\n>Script\n```uts\n\n\texport default {\n\t\tdata() {\n\t\t\treturn {\n\t\t\t\tdata: [] as Array,\n\t\t\t\tloadMoreText: \"加载中...\",\n\t\t\t\tshowLoadMore: false,\n\t\t\t\tmax: 0\n\t\t\t}\n\t\t},\n\t\tonLoad() {\n\t\t\tthis.initData();\n\t\t},\n\t\tonReachBottom() {\n\t\t\tconsole.log(\"onReachBottom\");\n\t\t\tif (this.max > 40) {\n\t\t\t\tthis.loadMoreText = \"没有更多数据了!\"\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.showLoadMore = true;\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.setListData();\n\t\t\t}, 300);\n\t\t},\n\t\tonPullDownRefresh() {\n\t\t\tconsole.log('onPullDownRefresh');\n\t\t\tthis.initData();\n\t\t},\n\t\tmethods: {\n\t\t\tinitData(){\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tthis.max = 0;\n\t\t\t\t\tthis.data = [];\n\t\t\t\t\tlet data:Array = [];\n\t\t\t\t\tthis.max += 20;\n\t\t\t\t\tfor (let i:number = this.max - 19; i < this.max + 1; i++) {\n\t\t\t\t\t\tdata.push(i)\n\t\t\t\t\t}\n\t\t\t\t\tthis.data = this.data.concat(data);\n\t\t\t\t\tuni.stopPullDownRefresh();\n\t\t\t\t}, 300);\n\t\t\t},\n\t\t\tsetListData() {\n\t\t\t\tlet data:Array = [];\n\t\t\t\tthis.max += 10;\n\t\t\t\tfor (let i:number = this.max - 9; i < this.max + 1; i++) {\n\t\t\t\t\tdata.push(i)\n\t\t\t\t}\n\t\t\t\tthis.data = this.data.concat(data);\n\t\t\t}\n\t\t}\n\t}\n\n```\n\n:::"},"pageScrollTo":{"name":"## uni.pageScrollTo(options) @pagescrollto","description":"\n将页面滚动到目标位置\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [PageScrollToOptions](#pagescrolltooptions-values) | 是 | - | - |\n#### PageScrollToOptions 的属性值 @pagescrolltooptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| scrollTop | number \\| null | 否 | - | |\n| selector | string \\| null | 否 | - | |\n| offsetTop | number \\| null | 否 | - | |\n| duration | number \\| null | 否 | - | |\n| success | Function \\| null | 否 | - | |\n| fail | Function \\| null | 否 | - | |\n| complete | Function \\| null | 否 | - | |\n\n##### PageScrollToOptions 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| offsetTop | 3.91 | x | 4.0 |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### pageScrollTo 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[pageScrollTo](https://doc.dcloud.net.cn/uni-app-x/api/page-scroll-to.html)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.page.page-scroll-to)\n"},"page-scroll-to":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/page-scroll-to/page-scroll-to.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/page-scroll-to/page-scroll-to\n>Template\n```vue\n\n\n\n\n\n\n```\n>Script\n```uts\n\n export default {\n data() {\n return {\n title: 'pageScrollTo',\n }\n },\n methods: {\n scrollTo() {\n uni.pageScrollTo({\n scrollTop: 100,\n duration: 300,\n success: () => {\n console.log('success')\n },\n })\n },\n scrollToElement() {\n uni.pageScrollTo({\n selector: '.custom-element',\n duration: 300,\n success: () => {\n console.log('success')\n },\n })\n },\n },\n }\n\n```\n\n:::"},"getElementById":{"name":"## uni.getElementById(id) @getelementbyid","description":"\n返回一个匹配特定 ID 的元素, 如果不存在,返回 null。\\\n如果需要获取指定的节点类型,需要使用 as 进行类型转换。\\\nID 区分大小写,且应该是唯一的。如果存在多个匹配的元素,则返回第一个匹配的元素。\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| id | string.IDString \\| string | 是 | - | - |","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| interface \\| null | 否 | \n","compatibility":"### getElementById 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[getElementById](https://doc.dcloud.net.cn/uni-app-x/api/get-element.html)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.dom.get-element.getElementById)\n","example":"### 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/get-element-by-id/get-element-by-id.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-element-by-id/get-element-by-id\n>Template\n```vue\n\r\n\r\n\r\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n checked: false,\r\n homePagePath: '/pages/tabBar/component',\r\n launchOptionsPath: '',\r\n }\r\n },\r\n methods: {\r\n getElementByNotExistId() : Element | null {\r\n return uni.getElementById('not-exist-id')\r\n },\r\n changePageHeadBackgroundColor() {\r\n const pageHead = uni.getElementById('page-head')!\r\n pageHead.style.setProperty('background-color', 'red')\r\n },\r\n changeTextColor() {\r\n const text = uni.getElementById('text')!\r\n text.style.setProperty('color', 'red')\r\n },\r\n changeViewStyle() {\r\n const view = uni.getElementById('view')\r\n if (view !== null) {\r\n view.style.setProperty('width', '90%')\r\n view.style.setProperty('height', '50px')\r\n view.style.setProperty('background-color', '#007AFF')\r\n }\r\n },\r\n goMultipleRootNode() {\r\n uni.navigateTo({ url: '/pages/API/get-element-by-id/get-element-by-id-multiple-root-node' })\r\n }\r\n }\r\n }\r\n\n```\n\n:::"},"createSelectorQuery":{"name":"## uni.createSelectorQuery() @createselectorquery","description":"\n返回一个SelectorQuery对象实例\n","param":"","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [SelectorQuery](#selectorquery-values) | \n\n#### SelectorQuery 的方法 @selectorquery-values \n\n#### in(component?) @in\n\n将选择器的选取范围更改为自定义组件component内\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| component | any \\| null | 否 | - | |\n##### 返回值 \n\n| 类型 |\n| :- |\n| [SelectorQuery](#selectorquery-values) | \n\n\n\n#### select(selector) @select\n\n在当前页面下选择第一个匹配选择器selector的节点\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| selector | string | 是 | - | - |\n##### 返回值 \n\n| 类型 |\n| :- |\n| [NodesRef](#nodesref-values) | \n\n###### NodesRef 的方法 @nodesref-values \n\n##### boundingClientRect(callback?) @boundingclientrect\n\n添加节点的布局位置的查询请求,相对于显示区域,以像素为单位\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | Function \\| null | 否 | - | |\n###### 返回值 \n\n| 类型 |\n| :- |\n| [SelectorQuery](#selectorquery-values) | \n\n\n\n##### scrollOffset(callback) @scrolloffset\n\n添加节点的滚动位置查询请求,以像素为单位\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: any) => void | 是 | - | |\n###### 返回值 \n\n| 类型 |\n| :- |\n| [SelectorQuery](#selectorquery-values) | \n\n\n\n##### fields(fields, callback) @fields\n\n获取节点的相关信息,需要获取的字段在fields中指定\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| fields | [NodeField](#nodefield-values) | 是 | - | - |\n| callback | (result: any) => void | 是 | - | |\n###### NodeField 的属性值 @nodefield-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| id | boolean \\| null | 否 | - | |\n| dataset | boolean \\| null | 否 | - | |\n| rect | boolean \\| null | 否 | - | |\n| size | boolean \\| null | 否 | - | |\n| scrollOffset | boolean \\| null | 否 | - | |\n| properties | Array \\| null | 否 | - | |\n| computedStyle | Array \\| null | 否 | - | |\n| context | boolean \\| null | 否 | - | |\n\n###### NodeField 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| context | x | x | 4.0 |\n\n###### 返回值 \n\n| 类型 |\n| :- |\n| [SelectorQuery](#selectorquery-values) | \n\n\n\n##### context(callback) @context\n\n添加节点的 Context 对象查询请求\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: any) => void | 是 | - | |\n###### 返回值 \n\n| 类型 |\n| :- |\n| [SelectorQuery](#selectorquery-values) | \n\n###### context 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| x | x | 4.0 |\n\n\n##### node(callback) @node\n\n获取 Node 节点实例。目前支持 Canvas 的获取。\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: any) => void | 是 | - | - |\n###### 返回值 \n\n| 类型 |\n| :- |\n| [SelectorQuery](#selectorquery-values) | \n\n\n\n\n\n#### selectAll(selector) @selectall\n\n在当前页面下选择匹配选择器selector的所有节点\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| selector | string | 是 | - | - |\n##### 返回值 \n\n| 类型 |\n| :- |\n| [NodesRef](#nodesref-values) | \n\n\n\n#### selectViewport() @selectviewport\n\n选择显示区域\n\n##### 返回值 \n\n| 类型 |\n| :- |\n| [NodesRef](#nodesref-values) | \n\n\n\n#### exec(callback) @exec\n\n执行所有的请求\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: Array\\) => void \\| null | 是 | - | - |\n##### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| interface \\| null | 否 | \n\n\n","compatibility":"### createSelectorQuery 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.91 | x | 4.0 |\n","tutorial":"\n### 参见\n[createSelectorQuery](https://doc.dcloud.net.cn/uni-app-x/api/nodes-info.html)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.dom.nodes-info.createSelectorQuery)\n"},"nodes-info":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/nodes-info/nodes-info.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/nodes-info/nodes-info\n>Template\n```vue\n\n\n\n\n\n\n```\n>Script\n```uts\n\n type NodeInfoType = {\n left : number | null,\n top : number | null,\n right : number | null,\n bottom : number | null,\n width : number | null,\n height : number | null,\n }\n\n export default {\n data() {\n return {\n title: 'createSelectorQuery',\n nodeInfoList: [] as NodeInfoType[],\n //供自动化测试使用\n // resizeRectValid: false\n }\n },\n onResize() {\n //供自动化测试使用\n /* var rect12Element = uni.getElementById(\"rect-1-2\")\n if(rect12Element != null) {\n var domRect = rect12Element.getBoundingClientRect()\n if(domRect.width > 100) {\n this.resizeRectValid = true\n }\n } */\n },\n methods: {\n getNodeInfo() {\n uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => {\n this.nodeInfoList.length = 0\n const i = ret[0] as NodeInfo\n this.nodeInfoList.push({\n left: i.left,\n top: i.top,\n right: i.right,\n bottom: i.bottom,\n width: i.width,\n height: i.height,\n } as NodeInfoType)\n })\n },\n getAllNodeInfo() {\n uni.createSelectorQuery().selectAll('.rect').boundingClientRect().exec((ret) => {\n this.nodeInfoList.length = 0\n const array = ret[0] as NodeInfo[]\n array.forEach((i) => {\n this.nodeInfoList.push({\n left: i.left,\n top: i.top,\n right: i.right,\n bottom: i.bottom,\n width: i.width,\n height: i.height,\n } as NodeInfoType)\n })\n })\n }\n }\n }\n\n```\n\n:::"},"showActionSheet":{"name":"## uni.showActionSheet(options) @showactionsheet","description":"从底部向上弹出操作菜单","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [ShowActionSheetOptions](#showactionsheetoptions-values) | 是 | - | uni.showActionSheet函数参数定义 |\n#### ShowActionSheetOptions 的属性值 @showactionsheetoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| title | string \\| null | 否 | - | |\n| alertText | string \\| null | 否 | - | |\n| itemList | Array\\ | 是 | - | 按钮的文字数组 |\n| itemColor | string.ColorString \\| null | 否 | - | |\n| popover | interface \\| null | 否 | - | |\n| success | Function \\| null | 否 | - | uni.showActionSheet成功回调函数定义 |\n| fail | Function \\| null | 否 | - | uni.showActionSheet成功回调函数定义 |\n| complete | Function \\| null | 否 | - | uni.showActionSheet成功回调函数定义 |\n\n##### ShowActionSheetOptions 兼容性 \n| | Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- | :- |\n| popover | x | x | x | 4.0 |\n","returnValue":"","compatibility":"### showActionSheet 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9.0 | 3.9.0 | 4.0 |\n","tutorial":"\n### 参见\n[showActionSheet]([](https://uniapp.dcloud.net.cn/api/ui/prompt.html#showactionsheet))\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.ui.prompt.showActionSheet)\n","example":"### 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/action-sheet/action-sheet.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/action-sheet/action-sheet\n>Template\n```vue\n\r\n\n\n```\n>Script\n```uts\n\r\n type ItemType = {\r\n value : string,\r\n name : string,\r\n }\r\n export default {\r\n data() {\r\n return {\r\n title: 'action-sheet',\r\n itemColorCustom: false,\r\n itemContentLarge: false,\r\n itemNumLargeSelect: false,\r\n items: [{\r\n value: '标题',\r\n name: '有标题'\r\n },\r\n {\r\n value: '',\r\n name: '无标题'\r\n },\r\n {\r\n value: '超长标题测试内容,测试超过显示最大范围之后的样式-超长标题测试内容,测试超过显示最大范围之后的样式',\r\n name: '超长标题'\r\n }\r\n ] as ItemType[],\r\n current: 0,\r\n }\r\n },\n onLoad(){\n uni.showActionSheet({\n title: \"onLoad 调用示例,请手动取消\",\n itemList:['item1', 'item2'],\n })\n },\r\n methods: {\r\n radioChange(e : UniRadioGroupChangeEvent) {\r\n for (let i = 0; i < this.items.length; i++) {\r\n if (this.items[i].value === e.detail.value) {\r\n this.current = i;\r\n break;\r\n }\r\n }\r\n },\r\n itemContentLargeChange: function (e : UniSwitchChangeEvent) {\r\n this.itemContentLarge = e.detail.value\r\n },\r\n itemColorChange: function (e : UniSwitchChangeEvent) {\r\n this.itemColorCustom = e.detail.value\r\n },\r\n itemNumLargeChange: function (e : UniSwitchChangeEvent) {\r\n this.itemNumLargeSelect = e.detail.value\r\n },\r\n actionSheetTap() {\r\n\r\n let itemInfo = ['item1', 'item2', 'item3', 'item4']\r\n\r\n if (this.itemContentLarge) {\r\n itemInfo = ['两个黄鹂鸣翠柳,一行白鹭上青天。窗含西岭千秋雪,门泊东吴万里船', '水光潋滟晴方好,山色空蒙雨亦奇。 欲把西湖比西子,淡妆浓抹总相宜', '']\r\n }\n\n if (this.itemNumLargeSelect) {\r\n // 大量选项测试,不能超过6个元素 https://uniapp.dcloud.net.cn/api/ui/prompt.html#showactionsheet\r\n itemInfo = []\n for (var i = 1; i <= 10; i++) {\r\n itemInfo.push('两个黄鹂鸣翠柳,一行白鹭上青天');\r\n }\r\n }\r\n\r\n const that = this\r\n if (this.itemColorCustom) {\r\n uni.showActionSheet({\r\n title: this.items[this.current].value,\r\n itemList: itemInfo,\r\n itemColor: \"#ff00ff\",\r\n success: (e) => {\r\n console.log(e.tapIndex);\r\n uni.showToast({\r\n title: \"点击了第\" + e.tapIndex + \"个选项\",\r\n icon: \"none\"\r\n })\r\n },\r\n fail: (e) => {\r\n console.log(e);\r\n }\r\n })\r\n } else {\r\n uni.showActionSheet({\r\n title: this.items[this.current].value,\r\n itemList: itemInfo,\r\n success: (e) => {\r\n console.log(e.tapIndex);\r\n uni.showToast({\r\n title: \"点击了第\" + e.tapIndex + \"个选项\",\r\n icon: \"none\"\r\n })\r\n },\r\n fail: (e) => {\r\n console.log(e);\r\n uni.showToast({\r\n title: e.errMsg,\r\n icon: \"none\"\r\n })\r\n }\r\n })\r\n }\r\n },\r\n }\r\n }\r\n\n```\n\n:::"},"showLoading":{"name":"## uni.showLoading(options) @showloading","description":"显示 loading 提示框, 需主动调用 uni.hideLoading 才能关闭提示框。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [ShowLoadingOptions](#showloadingoptions-values) | 是 | - | uni.showLoading参数定义 |\n#### ShowLoadingOptions 的属性值 @showloadingoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| title | string | 是 | - | 提示的内容,长度与 icon 取值有关。 |\n| mask | boolean \\| null | 否 | - | |\n| success | Function \\| null | 否 | - | uni.showLoading成功回调函数定义 |\n| fail | Function \\| null | 否 | - | uni.showLoading失败回调函数定义 |\n| complete | Function \\| null | 否 | - | uni.showLoading完成回调函数定义 |\n","returnValue":"","compatibility":"### showLoading 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9.0 | 3.9.0 | 4.0 |\n","tutorial":"\n### 参见\n[showLoading]([](https://uniapp.dcloud.net.cn/api/ui/prompt.html#showloading))\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.ui.prompt.showLoading)\n","example":"### 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/loading/loading.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/loading/loading\n>Template\n```vue\n\n\n\n```\n>Script\n```uts\n\n type ItemType = {\n value : string\n name : string\n }\n export default {\n data() {\n return {\n title: 'loading',\n items: [\n {\n value: 'null',\n name: '无标题',\n },\n {\n value: '三秒后自动关闭',\n name: '普通标题',\n },\n {\n value: '超长文本内容,测试超出范围-超长文本内容,测试超出范围-三秒后自动关闭',\n name: '长标题',\n },\n ] as ItemType[],\n current: 0,\n maskSelect: false,\n titleSelect: \"null\"\n }\n },\n onLoad(){\n uni.showLoading({\n \ttitle:'onLoad 调用示例,2秒后消失'\n })\n setTimeout(function() {\n uni.hideLoading()\n }, 2000);\n },\n methods: {\n\n radioChange(e : UniRadioGroupChangeEvent) {\n const selected = this.items.find((item) : boolean => {\n return item.value == e.detail.value\n })\n if (selected != null) {\n this.titleSelect = selected.value\n }\n },\n maskChange: function (e : UniSwitchChangeEvent) {\n this.maskSelect = e.detail.value\n },\n showLoading: function () {\n\n console.log(this.titleSelect)\n if (this.titleSelect == \"null\") {\n uni.showLoading({\n title: \"\",\n mask: this.maskSelect\n });\n } else {\n uni.showLoading({\n title: this.titleSelect,\n mask: this.maskSelect\n });\n }\n setTimeout(() => {\n this.hideLoading();\n }, 3000);\n },\n hideLoading: function () {\n uni.hideLoading();\n }\n }\n }\n\n```\n\n:::"},"showModal":{"name":"## uni.showModal(options) @showmodal","description":"显示模态弹窗,可以只有一个确定按钮,也可以同时有确定和取消按钮。类似于一个API整合了 html 中:alert、confirm。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [ShowModalOptions](#showmodaloptions-values) | 是 | - | uni.showModal 参数定义 |\n#### ShowModalOptions 的属性值 @showmodaloptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| title | string \\| null | 否 | - | |\n| content | string \\| null | 否 | - | |\n| showCancel | boolean \\| null | 否 | true
是否显示取消按钮,默认为 true | |\n| cancelText | string \\| null | 否 | - | |\n| cancelColor | string.ColorString \\| null | 否 | - | |\n| confirmText | string \\| null | 否 | - | |\n| confirmColor | string.ColorString \\| null | 否 | - | |\n| editable | boolean \\| null | 否 | false
是否显示输入框 | |\n| placeholderText | string \\| null | 否 | - | |\n| success | Function \\| null | 否 | - | uni.showModal成功回调函数定义 |\n| fail | Function \\| null | 否 | - | uni.showModal失败回调函数定义 |\n| complete | Function \\| null | 否 | - | uni.showModal完成回调函数定义 |\n","returnValue":"","compatibility":"### showModal 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9.0 | 3.9.0 | 4.0 |\n","tutorial":"\n### 参见\n[showModal]([](https://uniapp.dcloud.net.cn/api/ui/prompt.html#showmodal))\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.ui.prompt.showModal)\n","example":"### 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/modal/modal.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/modal/modal\n>Template\n```vue\n\n\n\n\n```\n>Script\n```uts\n\n type ItemType = {\n value : string,\n name : string,\n }\n export default {\n data() {\n return {\n title: 'modal',\n showCancelSelect: false,\n cancelTextSelect: false,\n confirmTextSelect: false,\n editableSelect: false,\n placeholderTextSelect: false,\n exeRet: \"\",\n items: [{\n value: '标题',\n name: '有标题'\n },\n {\n value: '',\n name: '无标题'\n },\n {\n value: '超长标题测试内容,测试超过显示最大范围之后的样式-超长标题测试内容,测试超过显示最大范围之后的样式',\n name: '超长标题'\n }\n ] as ItemType[],\n current: 0\n }\n },\n onLoad() {\n uni.showModal({\n title: \"onLoad 调用示例,请手动取消\",\n showCancel: false\n })\n },\n methods: {\n showCancelChange: function (e : UniSwitchChangeEvent) {\n this.showCancelSelect = e.detail.value\n },\n cancelTextChange: function (e : UniSwitchChangeEvent) {\n this.cancelTextSelect = e.detail.value\n },\n confirmTextChange: function (e : UniSwitchChangeEvent) {\n this.confirmTextSelect = e.detail.value\n },\n editableChange: function (e : UniSwitchChangeEvent) {\n this.editableSelect = e.detail.value\n },\n placeholderTextChange: function (e : UniSwitchChangeEvent) {\n this.placeholderTextSelect = e.detail.value\n },\n radioChange(e : UniRadioGroupChangeEvent) {\n for (let i = 0; i < this.items.length; i++) {\n if (this.items[i].value === e.detail.value) {\n this.current = i;\n break;\n }\n }\n },\n modalTap: function () {\n let cancelTextVal : string\n let cancelColorVal = ''\n if (this.cancelTextSelect) {\n cancelTextVal = \"修改后的取消文本\"\n cancelColorVal = \"#ff00ff\"\n } else {\n cancelTextVal = \"取消\"\n }\n\n let confirmTextVal = '确定'\n let confirmColorVal = ''\n if (this.confirmTextSelect) {\n confirmTextVal = \"修改后的确定文本\"\n confirmColorVal = \"#00ffff\"\n }\n\n let placeholderTextVal = ''\n let contentVal = \"弹窗内容,告知当前状态、信息和解决方法,描述文字尽量控制在三行内\"\n if (this.placeholderTextSelect) {\n placeholderTextVal = \"定制提示信息\"\n contentVal = \"\"\n }\n uni.showModal({\n title: this.items[this.current].value,\n editable: this.editableSelect,\n placeholderText: placeholderTextVal,\n content: contentVal,\n showCancel: this.showCancelSelect,\n cancelText: cancelTextVal,\n cancelColor: cancelColorVal,\n confirmText: confirmTextVal,\n confirmColor: confirmColorVal,\n success: (res) => {\n this.exeRet = JSON.stringify(res)\n },\n fail: (res) => {\n this.exeRet = JSON.stringify(res)\n }\n })\n }\n }\n }\n\n```\n\n:::"},"showToast":{"name":"## uni.showToast(options) @showtoast","description":"显示消息提示框","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [ShowToastOptions](#showtoastoptions-values) | 是 | - | uni.showToast参数定义 |\n#### ShowToastOptions 的属性值 @showtoastoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| title | string | 是 | - | 提示的内容,长度与 icon 取值有关。 |\n| icon | \"success\" \\| \"error\" \\| \"loading\" \\| \"none\" | 否 | - | icon值说明 success: 显示成功图标,error: 显示错误图标; loading: 显示加载图标;none: 不显示图标。 |\n| image | string.ImageURIString \\| null | 否 | - | |\n| mask | boolean \\| null | 否 | - | |\n| duration | number \\| null | 否 | - | |\n| position | \"top\" \\| \"center\" \\| \"bottom\" | 否 | - | position值说明(仅App生效) top: 居上显示; center: 居中显示;bottom: 居底显示 |\n| success | Function \\| null | 否 | - | uni.showToast成功回调函数定义 |\n| fail | Function \\| null | 否 | - | uni.showToast失败回调函数定义 |\n| complete | Function \\| null | 否 | - | uni.showToast完成回调函数定义 |\n","returnValue":"","compatibility":"### showToast 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9.0 | 3.9.0 | 4.0 |\n","tutorial":"\n### 参见\n[showToast]([](https://uniapp.dcloud.net.cn/api/ui/prompt.html#showtoast))\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.ui.prompt.showToast)\n","example":"### 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/toast/toast.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/toast/toast\n>Template\n```vue\n\n\n\n\n```\n>Script\n```uts\n\n export default {\n data() {\n return {\n title: 'toast',\n exeRet: ''\n }\n },\n onLoad() {\n uni.showToast({\n title: 'onLoad 调用示例,2秒后消失'\n })\n setTimeout(function () {\n uni.hideToast()\n }, 2000);\n },\n methods: {\n toast1Tap: function () {\n uni.showToast({\n title: \"默认\",\n success: (res) => {\n this.exeRet = \"success:\" + JSON.stringify(res) + new Date()\n },\n fail: (res) => {\n this.exeRet = \"fail:\" + JSON.stringify(res)\n },\n })\n },\n toastTapIconError: function () {\n uni.showToast({\n title: \"默认\",\n icon: 'error',\n success: (res) => {\n this.exeRet = \"success:\" + JSON.stringify(res) + new Date()\n },\n fail: (res) => {\n this.exeRet = \"fail:\" + JSON.stringify(res)\n },\n })\n },\n toast2Tap: function () {\n uni.showToast({\n title: \"duration 3000\",\n duration: 3000,\n success: (res) => {\n this.exeRet = \"success:\" + JSON.stringify(res) + new Date()\n },\n fail: (res) => {\n this.exeRet = \"fail:\" + JSON.stringify(res)\n },\n })\n },\n toast3Tap: function () {\n uni.showToast({\n title: \"loading\",\n icon: \"loading\",\n duration: 5000,\n success: (res) => {\n this.exeRet = \"success:\" + JSON.stringify(res) + new Date()\n },\n fail: (res) => {\n this.exeRet = \"fail:\" + JSON.stringify(res)\n },\n })\n },\n toast4Tap: function () {\n uni.showToast({\n title: \"logo\",\n image: \"/static/uni.png\",\n success: (res) => {\n this.exeRet = \"success:\" + JSON.stringify(res) + new Date()\n },\n fail: (res) => {\n this.exeRet = \"fail:\" + JSON.stringify(res)\n },\n })\n },\n // #ifdef APP-PLUS\n toast5Tap: function () {\n uni.showToast({\n title: \"显示一段轻提示\",\n position: 'bottom',\n success: (res) => {\n this.exeRet = \"success:\" + JSON.stringify(res) + new Date()\n },\n fail: (res) => {\n this.exeRet = \"fail:\" + JSON.stringify(res)\n },\n })\n },\n // #endif\n hideToast: function () {\n uni.hideToast()\n }\n }\n }\n\n```\n\n:::"},"loadFontFace":{"name":"## uni.loadFontFace(options) @loadfontface","description":"\n动态加载网络字体\n","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [LoadFontFaceOptions](#loadfontfaceoptions-values) | 是 | - | - |\n#### LoadFontFaceOptions 的属性值 @loadfontfaceoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| global | boolean | 否 | - | 是否全局生效。微信小程序 '2.10.0'起支持全局生效,需在 app.vue 中调用。 |\n| family | string | 是 | - | 定义的字体名称 |\n| source | string | 是 | - | 字体资源的地址 |\n| desc | [LoadFontFaceOptionDesc](#loadfontfaceoptiondesc-values) | 否 | - | 可选的字体描述符 |\n| success | (result: [AsyncApiSuccessResult](#asyncapisuccessresult-values)) => void | 否 | - | 接口调用成功的回调函数 |\n| fail | (error: [LoadFontFaceError](#loadfontfaceerror-values)) => void | 否 | - | 接口调用失败的回调函数 |\n| complete | (res: [AsyncApiResult](#asyncapiresult-values)) => void | 否 | - | 接口调用结束的回调函数(调用成功、失败都会执行) |\n\n##### LoadFontFaceOptionDesc 的属性值 @loadfontfaceoptiondesc-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| style | string \\| null | 否 | - | |\n| weight | string \\| null | 否 | - | |\n| variant | string \\| null | 否 | - | |\n\n##### AsyncApiSuccessResult 的属性值 @asyncapisuccessresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### LoadFontFaceError 的属性值 @loadfontfaceerror-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errCode | 4 \\| 99 \\| 101 \\| 100001 \\| 100002 \\| 200001 \\| 300001 \\| 300002 | 是 | - | 错误码
- 4: 框架内部异常
- 99: page is not ready
- 101: 参数错误
- 100001: family is null
- 100002: source is null
- 200001: local font not found
- 300001: same source task is loading
- 300002: download fail |\n| errSubject | string | 是 | - | 统一错误主题(模块)名称 |\n| errMsg | string | 是 | - | 统一错误描述信息 |\n| data | any \\| null | 否 | - | |\n| cause | interface \\| null | 否 | - | |\n| name | string | 是 | - | - |\n| message | string | 是 | - | - |\n\n##### AsyncApiResult 的属性值 @asyncapiresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | - |\n\n##### LoadFontFaceOptions 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| global | √ | x | 4.0 |\n| family | √ | x | 4.0 |\n| source | √ | x | 4.0 |\n| desc | x | x | 4.0 |\n| success | √ | x | 4.0 |\n| fail | √ | x | 4.0 |\n| complete | √ | x | 4.0 |\n","returnValue":"### 返回值 \n\n| 类型 | 必备 |\n| :- | :- |\n| Promise \\| null | 否 | \n","compatibility":"### loadFontFace 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| √ | x | 4.0 |\n","tutorial":"\n### 参见\n[loadFontFace](https://doc.dcloud.net.cn/uni-app-x/api/load-font-face.html)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.ui.load-font-face)\n"},"load-font-face":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/load-font-face/load-font-face.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/load-font-face/load-font-face\n>Template\n```vue\n\n\n\n\n\n```\n>Script\n```uts\n\n export default {\n data() {\n return {\n uniIcon1: '\\ue100',\n uniIcon2: '\\ue101',\n }\n },\n onLoad() {\n uni.loadFontFace({\n global: true,\n family: 'UniFontFamily',\n source: \"url('/static/font/uni.ttf')\",\n success() {\n console.log('global loadFontFace uni.ttf success')\n },\n fail(error) {\n console.warn('global loadFontFace uni.ttf fail', error.errMsg)\n },\n })\n uni.loadFontFace({\n family: 'AlimamaDaoLiTiTTF',\n source:\n \"url('https://qiniu-web-assets.dcloud.net.cn/uni-app-x/static/font/AlimamaDaoLiTi.ttf')\",\n success() {\n console.log('loadFontFace Remote AlimamaDaoLiTi.ttf success')\n },\n fail(error) {\n console.warn('loadFontFace Remote AlimamaDaoLiTi.ttf fail', error.errMsg)\n },\n })\n uni.loadFontFace({\n family: 'AlimamaDaoLiTiOTF',\n source: \"url('/static/font/AlimamaDaoLiTi.otf')\",\n success() {\n console.log('loadFontFace AlimamaDaoLiTi.otf success')\n },\n fail(error) {\n console.warn('loadFontFace AlimamaDaoLiTi.otf fail', error.errMsg)\n },\n })\n uni.loadFontFace({\n family: 'AlimamaDaoLiTiWOFF',\n source: \"url('/static/font/AlimamaDaoLiTi.woff')\",\n success() {\n console.log('loadFontFace AlimamaDaoLiTi.woff success')\n },\n fail(error) {\n console.warn('loadFontFace AlimamaDaoLiTi.woff fail', error.errMsg)\n },\n })\n uni.loadFontFace({\n family: 'AlimamaDaoLiTiWOFF2',\n source: \"url('/static/font/AlimamaDaoLiTi.woff2')\",\n success() {\n console.log('loadFontFace AlimamaDaoLiTi.woff2 success')\n },\n fail(error) {\n console.warn('loadFontFace AlimamaDaoLiTi.woff2 fail', error.errMsg)\n },\n })\n },\n methods: {\n navigateToChild() {\n uni.navigateTo({\n url: '/pages/API/load-font-face/load-font-face-child',\n })\n },\n },\n }\n\n```\n\n:::"},"request":{"name":"## uni.request(param) @request","description":"发起网络请求。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| param | [RequestOptions\\](#requestoptions-values) | 是 | - | 网络请求参数 |\n#### RequestOptions\\ 的属性值 @requestoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string | 是 | - | 开发者服务器接口地址 |\n| data | any \\| null | 否 | null | |\n| header | interface \\| null | 否 | null | |\n| method | Union \\| null | 否 | \"GET\" | 请求方法
- GET GET方法请求一个指定资源的表示形式,使用 GET 的请求应该只被用于获取数据。
- POST POST方法用于将实体提交到指定的资源,通常导致在服务器上的状态变化或副作用。
- PUT PUT方法用有效载荷请求替换目标资源的所有当前表示。
- PATCH PATCH方法用于对资源应用部分修改。
- DELETE DELETE方法删除指定的资源。
- HEAD HEAD方法请求一个与GET请求的响应相同的响应,但没有响应体。
- OPTIONS OPTIONS 方法用于描述目标资源的通信选项。 |\n| timeout | number \\| null | 否 | 60000 | |\n| firstIpv4 | boolean \\| null | 否 | false | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [RequestTask](#requesttask-values) | \n\n#### RequestTask 的方法 @requesttask-values \n\n#### abort() @abort\n中断网络请求。\n\n\n##### abort 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | - |\n\n\n##### 参见\n[abort](https://uniapp.dcloud.net.cn/api/request/request.html#request)\n","compatibility":"### request 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[request](https://uniapp.dcloud.net.cn/api/request/request.html)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.request)\n","example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/request/request.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/request/request\n>Template\n```vue\n\r\n\r\n\n```\n>Script\n```uts\n\r\n const duration = 2000\r\n const methodMap = {\r\n \"GET\": \"/api/http/method/get\",\r\n \"POST\": \"/api/http/method/post\",\r\n \"PUT\": \"/api/http/method/put\",\r\n \"DELETE\": \"/api/http/method/delete\",\r\n \"PATCH\": \"/api/http/method/patch\",\r\n \"OPTIONS\": \"/api/http/method/options\",\r\n \"HEAD\": \"/api/http/method/head\"\r\n }\r\n\r\n\r\n export default {\r\n data() {\r\n return {\r\n title: 'request',\r\n res: '',\r\n task: null as RequestTask | null,\r\n host: \"https://request.dcloud.net.cn\",\r\n url: \"/api/http/method/get\",\r\n method: \"GET\" as RequestMethod | null,\r\n data: null as any | null,\r\n header: null as UTSJSONObject | null,\r\n errorCodeUrls: [\r\n \"/api/http/statusCode/200\",\r\n \"/api/http/statusCode/204\",\r\n \"/api/http/statusCode/301\",\r\n \"/api/http/statusCode/302\",\r\n \"/api/http/statusCode/307\",\r\n \"/api/http/statusCode/400\",\r\n \"/api/http/statusCode/401\",\r\n \"/api/http/statusCode/403\",\r\n \"/api/http/statusCode/404\",\r\n \"/api/http/statusCode/405\",\r\n \"/api/http/statusCode/500\",\r\n \"/api/http/statusCode/502\",\r\n \"/api/http/statusCode/503\",\r\n \"/api/http/statusCode/504\",\r\n ],\r\n headerUrls: [\r\n \"/api/http/header/ua\",\r\n \"/api/http/header/referer\",\r\n \"/api/http/header/requestCookie\",\r\n \"/api/http/header/setCookie\",\r\n \"/api/http/header/deleteCookie\"\r\n ],\r\n contentTypeUrls: [\r\n \"/api/http/contentType/text/plain\",\r\n \"/api/http/contentType/text/html\",\r\n \"/api/http/contentType/text/xml\",\r\n \"/api/http/contentType/image/gif\",\r\n \"/api/http/contentType/image/jpeg\",\r\n \"/api/http/contentType/image/png\",\r\n \"/api/http/contentType/application/json\",\r\n \"/api/http/contentType/application/octetStream\",\r\n ],\r\n postUrls: [\r\n \"/api/http/contentType/json\",\r\n \"/api/http/contentType/xWwwFormUrlencoded\",\r\n ],\r\n //自动化测试例专用\r\n jest_result: false\r\n }\r\n },\r\n onLoad() {\r\n },\r\n onUnload() {\r\n uni.hideLoading();\r\n this.task?.abort();\r\n },\r\n methods: {\r\n changeMethod(e : RequestMethod) {\r\n this.method = e;\r\n this.url = methodMap[e] as string;\r\n this.data = null;\r\n this.header = null;\r\n },\r\n changeUrl(e : string) {\r\n this.method = \"GET\";\r\n this.url = e;\r\n this.data = null;\r\n this.header = null;\r\n },\r\n changeUrlFromPost(e : string) {\r\n this.method = \"POST\";\r\n this.url = e;\r\n switch (e) {\r\n case \"/api/http/contentType/json\":\r\n this.header = {\r\n \"Content-Type\": \"application/json\"\r\n };\r\n this.data = {\r\n \"hello\": \"world\"\r\n };\r\n break;\r\n case \"/api/http/contentType/xWwwFormUrlencoded\":\r\n this.header = {\r\n \"Content-Type\": \"application/x-www-form-urlencoded\"\r\n };\r\n this.data = \"hello=world\";\r\n break;\r\n }\r\n },\r\n sendRequest() {\r\n uni.showLoading({\r\n title: \"请求中...\"\r\n })\r\n this.task = uni.request({\r\n url: this.host + this.url,\r\n // dataType: \"json\",\r\n // responseType: \"json\",\r\n method: this.method,\r\n data: this.data,\r\n header: this.header,\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: (res) => {\r\n console.log('request success', JSON.stringify(res.data))\r\n console.log('request success header is :', JSON.stringify(res.header))\r\n uni.showToast({\r\n title: '请求成功',\r\n icon: 'success',\r\n mask: true,\r\n duration: duration\r\n });\r\n this.res = '请求结果 : ' + JSON.stringify(res);\r\n },\r\n fail: (err) => {\r\n console.log('request fail', err);\r\n uni.showModal({\r\n content: err.errMsg,\r\n showCancel: false\r\n });\r\n },\r\n complete: () => {\r\n uni.hideLoading()\r\n },\r\n });\r\n },\r\n //自动化测试例专用\r\n jest_request() {\r\n uni.request({\r\n url: this.host + this.url,\r\n // dataType: \"json\",\r\n // responseType: \"json\",\r\n method: this.method,\r\n data: this.data,\r\n header: this.header,\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_result = true;\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n jest_set_cookie() {\r\n uni.request({\r\n url: this.host + \"/api/http/header/setCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_cookie_request(true)\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n jest_delete_cookie() {\r\n uni.request({\r\n url: this.host + \"/api/http/header/deleteCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_cookie_request(false)\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n jest_cookie_request(needCookie : boolean) {\r\n uni.request({\r\n url: this.host + \"/api/http/header/requestCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: (res) => {\r\n const requestCookie = (res.data as UTSJSONObject).getJSON(\"data\")?.getAny(\"requestCookie\")\r\n console.log(\"requestCookie \", requestCookie);\r\n if (requestCookie instanceof Array) {\r\n this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0\r\n } else {\r\n this.jest_result = needCookie ? (requestCookie as UTSJSONObject).toMap().size > 0 : (requestCookie as UTSJSONObject).toMap().size == 0\r\n }\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n }\r\n }\r\n\n```\n\n:::"},"uploadFile":{"name":"## uni.uploadFile(options) @uploadfile","description":"将本地资源上传到开发者服务器。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [UploadFileOptions](#uploadfileoptions-values) | 是 | - | - |\n#### UploadFileOptions 的属性值 @uploadfileoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string | 是 | - | 开发者服务器 url |\n| filePath | string \\| null | 否 | null | |\n| name | string \\| null | 否 | null | |\n| files | Array \\| null | 否 | null | |\n| header | interface \\| null | 否 | null | |\n| formData | interface \\| null | 否 | null | |\n| timeout | number \\| null | 否 | 120000 | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [UploadTask](#uploadtask-values) | \n\n#### UploadTask 的方法 @uploadtask-values \n\n#### abort() @abort\n中断上传任务。\n\n\n##### abort 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[abort](https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile)\n\n#### onProgressUpdate(callback) @onprogressupdate\n监听上传进度变化。\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnProgressUpdateResult](#onprogressupdateresult-values)) => void | 是 | - | - |\n###### OnProgressUpdateResult 的属性值 @onprogressupdateresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| progress | number | 是 | - | 上传进度百分比 |\n| totalBytesSent | number | 是 | - | 已经上传的数据长度,单位 Bytes |\n| totalBytesExpectedToSend | number | 是 | - | 预期需要上传的数据总长度,单位 Bytes |\n\n\n##### onProgressUpdate 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | - |\n\n\n##### 参见\n[onProgressUpdate](https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile)\n","compatibility":"### uploadFile 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[uploadFile](https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.upload-file)\n"},"upload-file":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/upload-file/upload-file.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/upload-file/upload-file\n>Template\n```vue\n\r\n\r\n\r\n\r\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n title: 'uploadFile',\r\n imageSrc: '',\r\n task: null as UploadTask | null,\r\n //自动化测试例专用\r\n jest_result: false,\r\n }\r\n },\r\n onLoad() {\r\n },\r\n onUnload() {\r\n this.imageSrc = '';\r\n uni.hideLoading();\r\n this.task?.abort();\r\n },\r\n methods: {\r\n chooseImage: function () {\r\n uni.chooseImage({\r\n count: 1,\r\n sizeType: ['compressed'],\r\n sourceType: ['album'],\r\n success: (res) => {\r\n console.log('chooseImage success, temp path is', res.tempFilePaths[0])\r\n var imageSrc = res.tempFilePaths[0]\r\n uni.showLoading({\r\n title: '上传中'\r\n })\r\n this.task = uni.uploadFile({\r\n url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址\r\n filePath: imageSrc,\r\n name: 'file',\r\n formData: {\r\n 'user': 'test'\r\n },\r\n success: (res) => {\r\n console.log('uploadImage success, res is:', res)\r\n uni.hideLoading();\r\n uni.showToast({\r\n title: '上传成功',\r\n icon: 'success',\r\n duration: 1000\r\n })\r\n this.imageSrc = imageSrc\r\n },\r\n fail: (err) => {\r\n console.log('uploadImage fail', err);\r\n uni.hideLoading();\r\n uni.showModal({\r\n content: err.errMsg,\r\n showCancel: false\r\n });\r\n },\r\n });\r\n },\r\n fail: (err) => {\r\n console.log('chooseImage fail', err)\r\n }\r\n })\r\n },\r\n //自动化测试例专用\r\n jest_uploadFile() {\r\n const imageSrc = \"/static/uni.png\";\r\n this.task = uni.uploadFile({\r\n url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址\r\n filePath: imageSrc,\r\n name: 'file',\r\n formData: {\r\n 'user': 'test'\r\n },\r\n success: () => {\r\n this.jest_result = true;\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n })\r\n },\r\n jest_set_cookie() {\r\n uni.request({\r\n url: \"https://request.dcloud.net.cn/api/http/header/setCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_cookie_upload(true)\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n\r\n jest_delete_cookie() {\r\n uni.request({\r\n url: \"https://request.dcloud.net.cn/api/http/header/deleteCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_cookie_upload(false)\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n jest_cookie_upload(needCookie : boolean) {\r\n const imageSrc = \"/static/uni.png\";\r\n this.task = uni.uploadFile({\r\n url: 'https://request.dcloud.net.cn/api/http/header/upload',\r\n filePath: imageSrc,\r\n name: 'file',\r\n success: (res : UploadFileSuccess) => {\r\n const data = JSON.parseObject(res.data)\r\n const errCode = data?.getNumber(\"errCode\")\r\n if (errCode != null && errCode == 1000) {\r\n this.jest_result = needCookie ? false : true;\r\n } else {\r\n this.jest_result = needCookie ? true : false;\r\n }\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n })\r\n },\r\n jest_files_upload() {\r\n const imageSrc = \"/static/uni.png\";\r\n this.task = uni.uploadFile({\r\n url: 'https://unidemo.dcloud.net.cn/upload',\r\n files: [\r\n {\r\n name: \"file1\",\r\n uri: imageSrc\r\n } as UploadFileOptionFiles,\r\n {\r\n name: \"file2\",\r\n uri: imageSrc\r\n } as UploadFileOptionFiles\r\n ],\r\n success: (res : UploadFileSuccess) => {\r\n if (res.statusCode == 200) {\r\n this.jest_result = true;\r\n }\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n })\r\n }\r\n }\r\n }\r\n\n```\n\n:::"},"downloadFile":{"name":"## uni.downloadFile(options) @downloadfile","description":"下载文件资源到本地,客户端直接发起一个 HTTP GET 请求,返回文件的本地临时路径。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [DownloadFileOptions](#downloadfileoptions-values) | 是 | - | - |\n#### DownloadFileOptions 的属性值 @downloadfileoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string | 是 | - | 下载资源的 url |\n| header | interface \\| null | 否 | null | |\n| filePath | string \\| null | 否 | null | |\n| timeout | number \\| null | 否 | 120000 | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [DownloadTask](#downloadtask-values) | \n\n#### DownloadTask 的方法 @downloadtask-values \n\n#### abort() @abort\n中断下载任务。\n\n\n##### abort 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | - |\n\n\n##### 参见\n[abort](https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile)\n\n#### onProgressUpdate(callback) @onprogressupdate\n监听下载进度变化。\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnProgressDownloadResult](#onprogressdownloadresult-values)) => void | 是 | - | - |\n###### OnProgressDownloadResult 的属性值 @onprogressdownloadresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| progress | number | 是 | - | 下载进度百分比 |\n| totalBytesWritten | number | 是 | - | 已经下载的数据长度,单位 Bytes |\n| totalBytesExpectedToWrite | number | 是 | - | 预期需要下载的数据总长度,单位 Bytes |\n\n\n##### onProgressUpdate 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | - |\n\n\n##### 参见\n[onProgressUpdate](https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile)\n","compatibility":"### downloadFile 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[downloadFile](https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.download-file)\n"},"download-file":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/download-file/download-file.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/download-file/download-file\n>Template\n```vue\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n title: 'downloadFile',\r\n imageSrc: '',\r\n task: null as DownloadTask | null,\r\n //自动化测试例专用\r\n jest_result: false\r\n }\r\n },\r\n onLoad() {\r\n },\r\n onUnload() {\r\n // this.imageSrc = '';\r\n uni.hideLoading();\r\n this.task?.abort();\r\n },\r\n methods: {\r\n downloadImage: function () {\r\n uni.showLoading({\r\n title: '下载中'\r\n })\r\n var self = this\r\n this.task = uni.downloadFile({\r\n url: \"https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png\",\r\n success: (res) => {\r\n console.log('downloadFile success, res is', res.tempFilePath)\r\n self.imageSrc = res.tempFilePath;\r\n uni.hideLoading();\r\n },\r\n fail: (err) => {\r\n console.log('downloadFile fail, err is:', err)\r\n uni.hideLoading();\r\n }\r\n });\r\n this.task?.onProgressUpdate((update) => {\r\n console.log(\"progress : \", update.progress);\r\n })\r\n },\r\n //自动化测试例专用\r\n jest_downloadFile() {\r\n uni.downloadFile({\r\n url: \"https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png\",\r\n success: () => {\r\n this.jest_result = true\r\n },\r\n fail: () => {\r\n this.jest_result = false\r\n }\r\n });\r\n },\n\n jest_set_cookie(){\n uni.request({\n url: \"https://request.dcloud.net.cn/api/http/header/setCookie\",\n method: \"GET\",\n timeout: 6000,\n sslVerify: false,\n withCredentials: true,\n firstIpv4: false,\n success: () => {\n this.jest_cookie_download(true)\n },\n fail: () => {\n this.jest_result = false;\n },\n });\n },\n\n jest_delete_cookie(){\n uni.request({\n url: \"https://request.dcloud.net.cn/api/http/header/deleteCookie\",\n method: \"GET\",\n timeout: 6000,\n sslVerify: false,\n withCredentials: true,\n firstIpv4: false,\n success: () => {\n this.jest_cookie_download(false)\n },\n fail: () => {\n this.jest_result = false;\n },\n });\n },\n jest_cookie_download(needCookie: boolean){\n uni.downloadFile({\n url: \"https://request.dcloud.net.cn/api/http/header/download\",\n success: () => {\n this.jest_result = needCookie ? true : false;\n },\n fail: () => {\n this.jest_result = needCookie ? false : true;\n }\n });\n }\r\n }\r\n }\r\n\n```\n\n:::"},"getNetworkType":{"name":"## uni.getNetworkType(options) @getnetworktype","description":"获取网络类型","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [GetNetworkTypeOptions](#getnetworktypeoptions-values) | 是 | - | - |\n#### GetNetworkTypeOptions 的属性值 @getnetworktypeoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"","compatibility":"### getNetworkType 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[getNetworkType](http://uniapp.dcloud.io/api/system/network?id=getnetworktype)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.get-network-type)\n"},"get-network-type":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/get-network-type/get-network-type.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-network-type/get-network-type\n>Template\n```vue\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n title: 'getNetworkType',\r\n hasNetworkType: false,\r\n networkType: '',\r\n connectedWifi: '',\r\n //自动化测试例专用\r\n jest_result: false,\r\n }\r\n },\r\n onLoad() {\r\n },\r\n onUnload: function () {\r\n this.networkType = '';\r\n this.hasNetworkType = false;\r\n },\r\n methods: {\r\n getNetworkType: function () {\r\n uni.getNetworkType({\r\n success: (res) => {\r\n console.log(res)\r\n this.hasNetworkType = true;\r\n this.networkType = res.networkType\r\n },\r\n fail: () => {\r\n uni.showModal({\r\n content: '获取失败!',\r\n showCancel: false\r\n })\r\n }\r\n })\r\n },\r\n clear: function () {\r\n this.hasNetworkType = false;\r\n this.networkType = '';\r\n this.connectedWifi = '';\r\n },\r\n //自动化测试例专用\r\n jest_getNetworkType() {\r\n uni.getNetworkType({\r\n success: () => {\r\n this.jest_result = true;\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n }\r\n })\r\n }\r\n }\r\n }\r\n\n```\n\n:::"},"connectSocket":{"name":"## connectSocket(options) @connectsocket","description":"创建一个 WebSocket 连接。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [ConnectSocketOptions](#connectsocketoptions-values) | 是 | - | - |\n#### ConnectSocketOptions 的属性值 @connectsocketoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string | 是 | - | 开发者服务器接口地址,必须是 wss 协议,且域名必须是后台配置的合法域名 |\n| header | interface \\| null | 否 | null | |\n| protocols | Array \\| null | 否 | null | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [SocketTask](#sockettask-values) | \n\n#### SocketTask 的方法 @sockettask-values \n\n#### send(options) @send\n通过 WebSocket 连接发送数据\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SendSocketMessageOptions](#sendsocketmessageoptions-values) | 是 | - | - |\n###### SendSocketMessageOptions 的属性值 @sendsocketmessageoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| data | any | 是 | - | 需要发送的内容 |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n\n\n##### send 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[send](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-send)\n\n#### close(options) @close\n关闭 WebSocket 连接\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [CloseSocketOptions](#closesocketoptions-values) | 是 | - | - |\n###### CloseSocketOptions 的属性值 @closesocketoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| code | number \\| null | 否 | 1000 | |\n| reason | string \\| null | 否 | \"\" | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n\n\n##### close 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[close](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-close)\n\n#### onOpen(callback) @onopen\n监听 WebSocket 连接打开事件\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketOpenCallbackResult](#onsocketopencallbackresult-values)) => void | 是 | - | - |\n###### OnSocketOpenCallbackResult 的属性值 @onsocketopencallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| header | any | 是 | - | 连接成功的 HTTP 响应 Header |\n\n\n##### onOpen 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[onOpen](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-onopen)\n\n#### onClose(callback) @onclose\n监听 WebSocket 连接关闭事件\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: any) => void | 是 | - | - |\n\n##### onClose 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[onClose](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-onclose)\n\n#### onError(callback) @onerror\n监听 WebSocket 错误\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [GeneralCallbackResult](#generalcallbackresult-values)) => void | 是 | - | - |\n\n##### onError 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[onError](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-onerror)\n\n#### onMessage(callback) @onmessage\n监听 WebSocket 接受到服务器的消息事件\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketMessageCallbackResult](#onsocketmessagecallbackresult-values)) => void | 是 | - | - |\n###### OnSocketMessageCallbackResult 的属性值 @onsocketmessagecallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| data | any | 是 | - | 服务器返回的消息 |\n\n\n##### onMessage 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[onMessage](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-onmessage)\n","compatibility":"### connectSocket 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[connectSocket](https://uniapp.dcloud.net.cn/api/request/websocket.html#connectsocket)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.connectSocket)\n"},"onSocketOpen":{"name":"## onSocketOpen(options) @onsocketopen","description":"监听WebSocket连接打开事件。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | (result: [OnSocketOpenCallbackResult](#onsocketopencallbackresult-values)) => void | 是 | - | - |","returnValue":"","compatibility":"### onSocketOpen 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[onSocketOpen](https://uniapp.dcloud.net.cn/api/request/websocket.html#onsocketopen)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.onSocketOpen)\n"},"onSocketError":{"name":"## onSocketError(callback) @onsocketerror","description":"下载文件资源到本地,客户端直接发起一个 HTTP GET 请求,返回文件的本地临时路径。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketErrorCallbackResult](#onsocketerrorcallbackresult-values)) => void | 是 | - | - |\n#### OnSocketErrorCallbackResult 的属性值 @onsocketerrorcallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | 错误信息 |\n","returnValue":"","compatibility":"### onSocketError 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[onSocketError](https://uniapp.dcloud.net.cn/api/request/websocket.html#onsocketerror)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.onSocketError)\n"},"sendSocketMessage":{"name":"## sendSocketMessage(options) @sendsocketmessage","description":"通过 WebSocket 连接发送数据,需要先 uni.connectSocket,并在 uni.onSocketOpen 回调之后才能发送。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SendSocketMessageOptions](#sendsocketmessageoptions-values) | 是 | - | - |\n#### SendSocketMessageOptions 的属性值 @sendsocketmessageoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| data | any | 是 | - | 需要发送的内容 |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"","compatibility":"### sendSocketMessage 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[sendSocketMessage](https://uniapp.dcloud.net.cn/api/request/websocket.html#sendsocketmessage)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.sendSocketMessage)\n"},"onSocketMessage":{"name":"## onSocketMessage(callback) @onsocketmessage","description":"监听WebSocket接受到服务器的消息事件。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketMessageCallbackResult](#onsocketmessagecallbackresult-values)) => void | 是 | - | - |\n#### OnSocketMessageCallbackResult 的属性值 @onsocketmessagecallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| data | any | 是 | - | 服务器返回的消息 |\n","returnValue":"","compatibility":"### onSocketMessage 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[onSocketMessage](https://uniapp.dcloud.net.cn/api/request/websocket.html#onsocketmessage)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.onSocketMessage)\n"},"closeSocket":{"name":"## closeSocket(options) @closesocket","description":"关闭 WebSocket 连接。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [CloseSocketOptions](#closesocketoptions-values) | 是 | - | - |\n#### CloseSocketOptions 的属性值 @closesocketoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| code | number \\| null | 否 | 1000 | |\n| reason | string \\| null | 否 | \"\" | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"","compatibility":"### closeSocket 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[closeSocket](https://uniapp.dcloud.net.cn/api/request/websocket.html#closesocket)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.closeSocket)\n"},"onSocketClose":{"name":"## onSocketClose(callback) @onsocketclose","description":"监听WebSocket关闭。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketCloseCallbackResult](#onsocketclosecallbackresult-values)) => void | 是 | - | - |\n#### OnSocketCloseCallbackResult 的属性值 @onsocketclosecallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| code | number | 是 | - | 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。\t |\n| reason | string | 是 | - | 一个可读的字符串,表示连接被关闭的原因。\t |\n","returnValue":"","compatibility":"### onSocketClose 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[onSocketClose](https://uniapp.dcloud.net.cn/api/request/websocket.html#onsocketclose)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.onSocketClose)\n"},"websocket-global":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/websocket-global/websocket-global.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/websocket-global/websocket-global\n>Template\n```vue\n\r\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n connected: false,\r\n connecting: false,\r\n msg: '',\r\n roomId: '',\r\n platform: '',\r\n }\r\n },\r\n computed: {\r\n showMsg() : string {\r\n if (this.connected) {\r\n if (this.msg.length > 0) {\r\n return '收到消息:' + this.msg\r\n } else {\r\n return '等待接收消息'\r\n }\r\n } else {\r\n return '尚未连接'\r\n }\r\n },\r\n },\r\n onLoad() {\r\n this.platform = uni.getSystemInfoSync().platform\r\n },\r\n onUnload() {\r\n uni.closeSocket({\r\n code: 1000,\r\n reason: 'close reason from client',\r\n success: (res : any) => {\r\n console.log('uni.closeSocket success', res)\r\n },\r\n fail: (err : any) => {\r\n console.log('uni.closeSocket fail', err)\r\n },\r\n } as CloseSocketOptions)\r\n uni.hideLoading()\r\n },\r\n methods: {\r\n connect() {\r\n if (this.connected || this.connecting) {\r\n uni.showModal({\r\n content: '正在连接或者已经连接,请勿重复连接',\r\n showCancel: false,\r\n })\r\n return\r\n }\r\n this.connecting = true\r\n uni.showLoading({\r\n title: '连接中...',\r\n })\r\n uni.connectSocket({\r\n url: 'ws://websocket.dcloud.net.cn',\r\n header: null,\r\n protocols: null,\r\n success: (res : any) => {\r\n // 这里是接口调用成功的回调,不是连接成功的回调,请注意\r\n console.log('uni.connectSocket success', res)\r\n },\r\n fail: (err : any) => {\r\n // 这里是接口调用失败的回调,不是连接失败的回调,请注意\r\n console.log('uni.connectSocket fail', err)\r\n },\r\n })\r\n uni.onSocketOpen((res) => {\r\n this.connecting = false\r\n this.connected = true\r\n uni.hideLoading()\r\n\r\n uni.showToast({\r\n icon: 'none',\r\n title: '连接成功',\r\n })\r\n console.log('onOpen', res)\r\n })\r\n uni.onSocketError((err) => {\r\n this.connecting = false\r\n this.connected = false\r\n uni.hideLoading()\r\n\r\n uni.showModal({\r\n content: '连接失败,可能是websocket服务不可用,请稍后再试',\r\n showCancel: false,\r\n })\r\n console.log('onError', err)\r\n })\r\n uni.onSocketMessage((res) => {\r\n this.msg = res.data as string\r\n console.log('onMessage', res)\r\n })\r\n uni.onSocketClose((res) => {\r\n this.connected = false\r\n this.msg = ''\r\n console.log('onClose', res)\r\n })\r\n },\r\n send() {\r\n uni.sendSocketMessage({\r\n data:\r\n 'from ' +\r\n this.platform +\r\n ' : ' +\r\n parseInt((Math.random() * 10000).toString()).toString(),\r\n success: (res : any) => {\r\n console.log(res)\r\n },\r\n fail: (err : any) => {\r\n console.log(err)\r\n },\r\n } as SendSocketMessageOptions)\r\n },\r\n close() {\r\n uni.closeSocket({\r\n code: 1000,\r\n reason: 'close reason from client',\r\n success: (res : any) => {\r\n console.log('uni.closeSocket success', res)\r\n },\r\n fail: (err : any) => {\r\n console.log('uni.closeSocket fail', err)\r\n },\r\n } as CloseSocketOptions)\r\n },\r\n },\r\n }\r\n\n```\n\n:::"},"getSystemInfo":{"name":"## uni.getSystemInfo(options) @getsysteminfo","description":"异步获取系统信息","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [GetSystemInfoOptions](#getsysteminfooptions-values) | 是 | - | - |\n#### GetSystemInfoOptions 的属性值 @getsysteminfooptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"","compatibility":"### getSystemInfo 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[getSystemInfo](http://uniapp.dcloud.io/api/system/info?id=getsysteminfo)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.get-system-info.getSystemInfo)\n"},"getSystemInfoSync":{"name":"## uni.getSystemInfoSync() @getsysteminfosync","description":"同步获取系统信息","param":"","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [GetSystemInfoResult](#getsysteminforesult-values) | \n\n#### GetSystemInfoResult 的属性值 @getsysteminforesult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| SDKVersion | string | 是 | - | 客户端基础库版本 |\n| appId | string | 是 | - | `manifest.json` 中应用appid。 |\n| appLanguage | string | 是 | - | 应用设置的语言。 |\n| appName | string | 是 | - | `manifest.json` 中应用名称。 |\n| appVersion | string | 是 | - | `manifest.json` 中应用版本名称。 |\n| appVersionCode | string | 是 | - | `manifest.json` 中应用版本名号。 |\n| brand | string | 是 | - | 手机品牌。 |\n| browserName | string | 是 | - | 浏览器名称。`App` 端是系统 webview 的名字,比如 wkwebview、chrome。小程序端为空 |\n| browserVersion | string | 是 | - | 浏览器版本、webview 版本。 |\n| deviceId | string | 是 | - | 设备 ID |\n| deviceBrand | string | 是 | - | 设备品牌。如:`apple`、`huawei`。 |\n| deviceModel | string | 是 | - | 设备型号 |\n| deviceType | \"phone\" \\| \"pad\" \\| \"tv\" \\| \"watch\" \\| \"pc\" \\| \"null\" \\| \"car\" \\| \"vr\" \\| \"appliance\" | 是 | - | 设备类型。 |\n| devicePixelRatio | number | 是 | - | 设备像素比 |\n| deviceOrientation | \"portrait\" \\| \"landscape\" | 是 | - | 设备方向。 |\n| language | string | 是 | - | 程序设置的语言 |\n| model | string | 是 | - | 手机型号 |\n| osName | \"ios\" \\| \"android\" \\| \"mac\" \\| \"windows\" \\| \"linux\" | 是 | - | 系统名称\t |\n| osVersion | string | 是 | - | 操作系统版本。如 ios 版本,andriod 版本 |\n| osLanguage | string | 是 | - | 操作系统语言 |\n| osTheme | \"light\" \\| \"dark\" | 否 | - | 操作系统主题
|\n| pixelRatio | number | 是 | - | 设备像素比 |\n| platform | \"ios\" \\| \"android\" \\| \"mac\" \\| \"windows\" \\| \"linux\" | 是 | - | 客户端平台 |\n| screenWidth | number | 是 | - | 屏幕宽度 |\n| screenHeight | number | 是 | - | 屏幕高度 |\n| statusBarHeight | number | 是 | - | 状态栏的高度 |\n| system | string | 是 | - | 操作系统版本 |\n| safeArea | [SafeArea](#safearea-values) | 是 | - | 在竖屏正方向下的安全区域 |\n| safeAreaInsets | [SafeAreaInsets](#safeareainsets-values) | 是 | - | 在竖屏正方向下的安全区域插入位置 |\n| ua | string | 是 | - | 用户标识。小程序端为空 |\n| ~~uniCompileVersion~~ | string | 是 | - | uni 编译器版本\n已废弃,仅为了向下兼容保留 |\n| uniCompilerVersion | string | 是 | - | uni 编译器版本 |\n| uniPlatform | \"app\" \\| \"web\" \\| \"mp-weixin\" \\| \"mp-alipay\" \\| \"mp-baidu\" \\| \"mp-toutiao\" \\| \"mp-lark\" \\| \"mp-qq\" \\| \"mp-kuaishou\" \\| \"mp-jd\" \\| \"mp-360\" \\| \"quickapp-webview\" \\| \"quickapp-webview-union\" \\| \"quickapp-webview-huawei\" | 是 | - | uni-app 运行平台。 |\n| uniRuntimeVersion | string | 是 | - | uni 运行时版本 |\n| ~~uniCompileVersionCode~~ | number | 是 | - | uni 编译器版本号\n已废弃,仅为了向下兼容保留 |\n| uniCompilerVersionCode | number | 是 | - | uni 编译器版本号 |\n| uniRuntimeVersionCode | number | 是 | - | uni 运行时版本号 |\n| ~~version~~ | string | 是 | - | 引擎版本号。已废弃,仅为了向下兼容保留 \n已废弃,仅为了向下兼容保留 |\n| romName | string | 是 | - | rom 名称。Android 部分机型获取不到值。iOS 恒为 `ios` |\n| romVersion | string | 是 | - | rom 版本号。Android 部分机型获取不到值。iOS 恒为 `ios 版本号` |\n| windowWidth | number | 是 | - | 可使用窗口宽度 |\n| windowHeight | number | 是 | - | 可使用窗口高度 |\n| windowTop | number | 是 | - | 可使用窗口的顶部位置 |\n| windowBottom | number | 是 | - | 可使用窗口的底部位置 |\n| osAndroidAPILevel | number \\| null | 否 | - | |\n\n##### SafeArea 的属性值 @safearea-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| left | number | 是 | - | 安全区域左上角横坐标 |\n| right | number | 是 | - | 安全区域右下角横坐标 |\n| top | number | 是 | - | 安全区域左上角纵坐标 |\n| bottom | number | 是 | - | 安全区域右下角纵坐标 |\n| width | number | 是 | - | 安全区域的宽度,单位逻辑像素 |\n| height | number | 是 | - | 安全区域的高度,单位逻辑像素 |\n\n##### SafeAreaInsets 的属性值 @safeareainsets-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| left | number | 是 | - | 安全区域左侧插入位置 |\n| right | number | 是 | - | 安全区域右侧插入位置 |\n| top | number | 是 | - | 安全区顶部插入位置 |\n| bottom | number | 是 | - | 安全区域底部插入位置 |\n\n##### GetSystemInfoResult 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| osTheme | √ | x | - |\n| osAndroidAPILevel | √ | x | - |\n","compatibility":"### getSystemInfoSync 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[getSystemInfoSync](http://uniapp.dcloud.io/api/system/info?id=getsysteminfosync)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.get-system-info.getSystemInfoSync)\n"},"get-system-info":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/get-system-info/get-system-info.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-system-info/get-system-info\n>Template\n```vue\n\r\n\r\n\n```\n>Script\n```uts\n\r\n const duration = 2000\r\n const methodMap = {\r\n \"GET\": \"/api/http/method/get\",\r\n \"POST\": \"/api/http/method/post\",\r\n \"PUT\": \"/api/http/method/put\",\r\n \"DELETE\": \"/api/http/method/delete\",\r\n \"PATCH\": \"/api/http/method/patch\",\r\n \"OPTIONS\": \"/api/http/method/options\",\r\n \"HEAD\": \"/api/http/method/head\"\r\n }\r\n\r\n\r\n export default {\r\n data() {\r\n return {\r\n title: 'request',\r\n res: '',\r\n task: null as RequestTask | null,\r\n host: \"https://request.dcloud.net.cn\",\r\n url: \"/api/http/method/get\",\r\n method: \"GET\" as RequestMethod | null,\r\n data: null as any | null,\r\n header: null as UTSJSONObject | null,\r\n errorCodeUrls: [\r\n \"/api/http/statusCode/200\",\r\n \"/api/http/statusCode/204\",\r\n \"/api/http/statusCode/301\",\r\n \"/api/http/statusCode/302\",\r\n \"/api/http/statusCode/307\",\r\n \"/api/http/statusCode/400\",\r\n \"/api/http/statusCode/401\",\r\n \"/api/http/statusCode/403\",\r\n \"/api/http/statusCode/404\",\r\n \"/api/http/statusCode/405\",\r\n \"/api/http/statusCode/500\",\r\n \"/api/http/statusCode/502\",\r\n \"/api/http/statusCode/503\",\r\n \"/api/http/statusCode/504\",\r\n ],\r\n headerUrls: [\r\n \"/api/http/header/ua\",\r\n \"/api/http/header/referer\",\r\n \"/api/http/header/requestCookie\",\r\n \"/api/http/header/setCookie\",\r\n \"/api/http/header/deleteCookie\"\r\n ],\r\n contentTypeUrls: [\r\n \"/api/http/contentType/text/plain\",\r\n \"/api/http/contentType/text/html\",\r\n \"/api/http/contentType/text/xml\",\r\n \"/api/http/contentType/image/gif\",\r\n \"/api/http/contentType/image/jpeg\",\r\n \"/api/http/contentType/image/png\",\r\n \"/api/http/contentType/application/json\",\r\n \"/api/http/contentType/application/octetStream\",\r\n ],\r\n postUrls: [\r\n \"/api/http/contentType/json\",\r\n \"/api/http/contentType/xWwwFormUrlencoded\",\r\n ],\r\n //自动化测试例专用\r\n jest_result: false\r\n }\r\n },\r\n onLoad() {\r\n },\r\n onUnload() {\r\n uni.hideLoading();\r\n this.task?.abort();\r\n },\r\n methods: {\r\n changeMethod(e : RequestMethod) {\r\n this.method = e;\r\n this.url = methodMap[e] as string;\r\n this.data = null;\r\n this.header = null;\r\n },\r\n changeUrl(e : string) {\r\n this.method = \"GET\";\r\n this.url = e;\r\n this.data = null;\r\n this.header = null;\r\n },\r\n changeUrlFromPost(e : string) {\r\n this.method = \"POST\";\r\n this.url = e;\r\n switch (e) {\r\n case \"/api/http/contentType/json\":\r\n this.header = {\r\n \"Content-Type\": \"application/json\"\r\n };\r\n this.data = {\r\n \"hello\": \"world\"\r\n };\r\n break;\r\n case \"/api/http/contentType/xWwwFormUrlencoded\":\r\n this.header = {\r\n \"Content-Type\": \"application/x-www-form-urlencoded\"\r\n };\r\n this.data = \"hello=world\";\r\n break;\r\n }\r\n },\r\n sendRequest() {\r\n uni.showLoading({\r\n title: \"请求中...\"\r\n })\r\n this.task = uni.request({\r\n url: this.host + this.url,\r\n // dataType: \"json\",\r\n // responseType: \"json\",\r\n method: this.method,\r\n data: this.data,\r\n header: this.header,\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: (res) => {\r\n console.log('request success', JSON.stringify(res.data))\r\n console.log('request success header is :', JSON.stringify(res.header))\r\n uni.showToast({\r\n title: '请求成功',\r\n icon: 'success',\r\n mask: true,\r\n duration: duration\r\n });\r\n this.res = '请求结果 : ' + JSON.stringify(res);\r\n },\r\n fail: (err) => {\r\n console.log('request fail', err);\r\n uni.showModal({\r\n content: err.errMsg,\r\n showCancel: false\r\n });\r\n },\r\n complete: () => {\r\n uni.hideLoading()\r\n },\r\n });\r\n },\r\n //自动化测试例专用\r\n jest_request() {\r\n uni.request({\r\n url: this.host + this.url,\r\n // dataType: \"json\",\r\n // responseType: \"json\",\r\n method: this.method,\r\n data: this.data,\r\n header: this.header,\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_result = true;\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n jest_set_cookie() {\r\n uni.request({\r\n url: this.host + \"/api/http/header/setCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_cookie_request(true)\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n jest_delete_cookie() {\r\n uni.request({\r\n url: this.host + \"/api/http/header/deleteCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_cookie_request(false)\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n jest_cookie_request(needCookie : boolean) {\r\n uni.request({\r\n url: this.host + \"/api/http/header/requestCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: (res) => {\r\n const requestCookie = (res.data as UTSJSONObject).getJSON(\"data\")?.getAny(\"requestCookie\")\r\n console.log(\"requestCookie \", requestCookie);\r\n if (requestCookie instanceof Array) {\r\n this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0\r\n } else {\r\n this.jest_result = needCookie ? (requestCookie as UTSJSONObject).toMap().size > 0 : (requestCookie as UTSJSONObject).toMap().size == 0\r\n }\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n }\r\n }\r\n\n```\n\n:::"},"uploadFile":{"name":"## uni.uploadFile(options) @uploadfile","description":"将本地资源上传到开发者服务器。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [UploadFileOptions](#uploadfileoptions-values) | 是 | - | - |\n#### UploadFileOptions 的属性值 @uploadfileoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string | 是 | - | 开发者服务器 url |\n| filePath | string \\| null | 否 | null | |\n| name | string \\| null | 否 | null | |\n| files | Array \\| null | 否 | null | |\n| header | interface \\| null | 否 | null | |\n| formData | interface \\| null | 否 | null | |\n| timeout | number \\| null | 否 | 120000 | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [UploadTask](#uploadtask-values) | \n\n#### UploadTask 的方法 @uploadtask-values \n\n#### abort() @abort\n中断上传任务。\n\n\n##### abort 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | x |\n\n\n##### 参见\n[abort](https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile)\n\n#### onProgressUpdate(callback) @onprogressupdate\n监听上传进度变化。\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnProgressUpdateResult](#onprogressupdateresult-values)) => void | 是 | - | - |\n###### OnProgressUpdateResult 的属性值 @onprogressupdateresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| progress | number | 是 | - | 上传进度百分比 |\n| totalBytesSent | number | 是 | - | 已经上传的数据长度,单位 Bytes |\n| totalBytesExpectedToSend | number | 是 | - | 预期需要上传的数据总长度,单位 Bytes |\n\n\n##### onProgressUpdate 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | - |\n\n\n##### 参见\n[onProgressUpdate](https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile)\n","compatibility":"### uploadFile 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[uploadFile](https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.upload-file)\n"},"upload-file":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/upload-file/upload-file.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/upload-file/upload-file\n>Template\n```vue\n\r\n\r\n\r\n\r\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n title: 'uploadFile',\r\n imageSrc: '',\r\n task: null as UploadTask | null,\r\n //自动化测试例专用\r\n jest_result: false,\r\n }\r\n },\r\n onLoad() {\r\n },\r\n onUnload() {\r\n this.imageSrc = '';\r\n uni.hideLoading();\r\n this.task?.abort();\r\n },\r\n methods: {\r\n chooseImage: function () {\r\n uni.chooseImage({\r\n count: 1,\r\n sizeType: ['compressed'],\r\n sourceType: ['album'],\r\n success: (res) => {\r\n console.log('chooseImage success, temp path is', res.tempFilePaths[0])\r\n var imageSrc = res.tempFilePaths[0]\r\n uni.showLoading({\r\n title: '上传中'\r\n })\r\n this.task = uni.uploadFile({\r\n url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址\r\n filePath: imageSrc,\r\n name: 'file',\r\n formData: {\r\n 'user': 'test'\r\n },\r\n success: (res) => {\r\n console.log('uploadImage success, res is:', res)\r\n uni.hideLoading();\r\n uni.showToast({\r\n title: '上传成功',\r\n icon: 'success',\r\n duration: 1000\r\n })\r\n this.imageSrc = imageSrc\r\n },\r\n fail: (err) => {\r\n console.log('uploadImage fail', err);\r\n uni.hideLoading();\r\n uni.showModal({\r\n content: err.errMsg,\r\n showCancel: false\r\n });\r\n },\r\n });\r\n },\r\n fail: (err) => {\r\n console.log('chooseImage fail', err)\r\n }\r\n })\r\n },\r\n //自动化测试例专用\r\n jest_uploadFile() {\r\n const imageSrc = \"/static/uni.png\";\r\n this.task = uni.uploadFile({\r\n url: 'https://unidemo.dcloud.net.cn/upload', //仅为示例,非真实的接口地址\r\n filePath: imageSrc,\r\n name: 'file',\r\n formData: {\r\n 'user': 'test'\r\n },\r\n success: () => {\r\n this.jest_result = true;\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n })\r\n },\r\n jest_set_cookie() {\r\n uni.request({\r\n url: \"https://request.dcloud.net.cn/api/http/header/setCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_cookie_upload(true)\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n\r\n jest_delete_cookie() {\r\n uni.request({\r\n url: \"https://request.dcloud.net.cn/api/http/header/deleteCookie\",\r\n method: \"GET\",\r\n timeout: 6000,\r\n sslVerify: false,\r\n withCredentials: false,\r\n firstIpv4: false,\r\n success: () => {\r\n this.jest_cookie_upload(false)\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n });\r\n },\r\n jest_cookie_upload(needCookie : boolean) {\r\n const imageSrc = \"/static/uni.png\";\r\n this.task = uni.uploadFile({\r\n url: 'https://request.dcloud.net.cn/api/http/header/upload',\r\n filePath: imageSrc,\r\n name: 'file',\r\n success: (res : UploadFileSuccess) => {\r\n const data = JSON.parseObject(res.data)\r\n const errCode = data?.getNumber(\"errCode\")\r\n if (errCode != null && errCode == 1000) {\r\n this.jest_result = needCookie ? false : true;\r\n } else {\r\n this.jest_result = needCookie ? true : false;\r\n }\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n })\r\n },\r\n jest_files_upload() {\r\n const imageSrc = \"/static/uni.png\";\r\n this.task = uni.uploadFile({\r\n url: 'https://unidemo.dcloud.net.cn/upload',\r\n files: [\r\n {\r\n name: \"file1\",\r\n uri: imageSrc\r\n } as UploadFileOptionFiles,\r\n {\r\n name: \"file2\",\r\n uri: imageSrc\r\n } as UploadFileOptionFiles\r\n ],\r\n success: (res : UploadFileSuccess) => {\r\n if (res.statusCode == 200) {\r\n this.jest_result = true;\r\n }\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n },\r\n })\r\n }\r\n }\r\n }\r\n\n```\n\n:::"},"downloadFile":{"name":"## uni.downloadFile(options) @downloadfile","description":"下载文件资源到本地,客户端直接发起一个 HTTP GET 请求,返回文件的本地临时路径。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [DownloadFileOptions](#downloadfileoptions-values) | 是 | - | - |\n#### DownloadFileOptions 的属性值 @downloadfileoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string | 是 | - | 下载资源的 url |\n| header | interface \\| null | 否 | null | |\n| filePath | string \\| null | 否 | null | |\n| timeout | number \\| null | 否 | 120000 | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [DownloadTask](#downloadtask-values) | \n\n#### DownloadTask 的方法 @downloadtask-values \n\n#### abort() @abort\n中断下载任务。\n\n\n##### abort 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | x |\n\n\n##### 参见\n[abort](https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile)\n\n#### onProgressUpdate(callback) @onprogressupdate\n监听下载进度变化。\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnProgressDownloadResult](#onprogressdownloadresult-values)) => void | 是 | - | - |\n###### OnProgressDownloadResult 的属性值 @onprogressdownloadresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| progress | number | 是 | - | 下载进度百分比 |\n| totalBytesWritten | number | 是 | - | 已经下载的数据长度,单位 Bytes |\n| totalBytesExpectedToWrite | number | 是 | - | 预期需要下载的数据总长度,单位 Bytes |\n\n\n##### onProgressUpdate 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | - |\n\n\n##### 参见\n[onProgressUpdate](https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile)\n","compatibility":"### downloadFile 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[downloadFile](https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.download-file)\n"},"download-file":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/download-file/download-file.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/download-file/download-file\n>Template\n```vue\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n title: 'downloadFile',\r\n imageSrc: '',\r\n task: null as DownloadTask | null,\r\n //自动化测试例专用\r\n jest_result: false\r\n }\r\n },\r\n onLoad() {\r\n },\r\n onUnload() {\r\n // this.imageSrc = '';\r\n uni.hideLoading();\r\n this.task?.abort();\r\n },\r\n methods: {\r\n downloadImage: function () {\r\n uni.showLoading({\r\n title: '下载中'\r\n })\r\n var self = this\r\n this.task = uni.downloadFile({\r\n url: \"https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png\",\r\n success: (res) => {\r\n console.log('downloadFile success, res is', res.tempFilePath)\r\n self.imageSrc = res.tempFilePath;\r\n uni.hideLoading();\r\n },\r\n fail: (err) => {\r\n console.log('downloadFile fail, err is:', err)\r\n uni.hideLoading();\r\n }\r\n });\r\n this.task?.onProgressUpdate((update) => {\r\n console.log(\"progress : \", update.progress);\r\n })\r\n },\r\n //自动化测试例专用\r\n jest_downloadFile() {\r\n uni.downloadFile({\r\n url: \"https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png\",\r\n success: () => {\r\n this.jest_result = true\r\n },\r\n fail: () => {\r\n this.jest_result = false\r\n }\r\n });\r\n },\n\n jest_set_cookie(){\n uni.request({\n url: \"https://request.dcloud.net.cn/api/http/header/setCookie\",\n method: \"GET\",\n timeout: 6000,\n sslVerify: false,\n withCredentials: true,\n firstIpv4: false,\n success: () => {\n this.jest_cookie_download(true)\n },\n fail: () => {\n this.jest_result = false;\n },\n });\n },\n\n jest_delete_cookie(){\n uni.request({\n url: \"https://request.dcloud.net.cn/api/http/header/deleteCookie\",\n method: \"GET\",\n timeout: 6000,\n sslVerify: false,\n withCredentials: true,\n firstIpv4: false,\n success: () => {\n this.jest_cookie_download(false)\n },\n fail: () => {\n this.jest_result = false;\n },\n });\n },\n jest_cookie_download(needCookie: boolean){\n uni.downloadFile({\n url: \"https://request.dcloud.net.cn/api/http/header/download\",\n success: () => {\n this.jest_result = needCookie ? true : false;\n },\n fail: () => {\n this.jest_result = needCookie ? false : true;\n }\n });\n }\r\n }\r\n }\r\n\n```\n\n:::"},"getNetworkType":{"name":"## uni.getNetworkType(options) @getnetworktype","description":"获取网络类型","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [GetNetworkTypeOptions](#getnetworktypeoptions-values) | 是 | - | - |\n#### GetNetworkTypeOptions 的属性值 @getnetworktypeoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"","compatibility":"### getNetworkType 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[getNetworkType](http://uniapp.dcloud.io/api/system/network?id=getnetworktype)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.get-network-type)\n"},"get-network-type":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/get-network-type/get-network-type.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-network-type/get-network-type\n>Template\n```vue\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n title: 'getNetworkType',\r\n hasNetworkType: false,\r\n networkType: '',\r\n connectedWifi: '',\r\n //自动化测试例专用\r\n jest_result: false,\r\n }\r\n },\r\n onLoad() {\r\n },\r\n onUnload: function () {\r\n this.networkType = '';\r\n this.hasNetworkType = false;\r\n },\r\n methods: {\r\n getNetworkType: function () {\r\n uni.getNetworkType({\r\n success: (res) => {\r\n console.log(res)\r\n this.hasNetworkType = true;\r\n this.networkType = res.networkType\r\n },\r\n fail: () => {\r\n uni.showModal({\r\n content: '获取失败!',\r\n showCancel: false\r\n })\r\n }\r\n })\r\n },\r\n clear: function () {\r\n this.hasNetworkType = false;\r\n this.networkType = '';\r\n this.connectedWifi = '';\r\n },\r\n //自动化测试例专用\r\n jest_getNetworkType() {\r\n uni.getNetworkType({\r\n success: () => {\r\n this.jest_result = true;\r\n },\r\n fail: () => {\r\n this.jest_result = false;\r\n }\r\n })\r\n }\r\n }\r\n }\r\n\n```\n\n:::"},"connectSocket":{"name":"## connectSocket(options) @connectsocket","description":"创建一个 WebSocket 连接。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [ConnectSocketOptions](#connectsocketoptions-values) | 是 | - | - |\n#### ConnectSocketOptions 的属性值 @connectsocketoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| url | string | 是 | - | 开发者服务器接口地址,必须是 wss 协议,且域名必须是后台配置的合法域名 |\n| header | interface \\| null | 否 | null | |\n| protocols | Array \\| null | 否 | null | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [SocketTask](#sockettask-values) | \n\n#### SocketTask 的方法 @sockettask-values \n\n#### send(options) @send\n通过 WebSocket 连接发送数据\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SendSocketMessageOptions](#sendsocketmessageoptions-values) | 是 | - | - |\n###### SendSocketMessageOptions 的属性值 @sendsocketmessageoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| data | any | 是 | - | 需要发送的内容 |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n\n\n##### send 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[send](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-send)\n\n#### close(options) @close\n关闭 WebSocket 连接\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [CloseSocketOptions](#closesocketoptions-values) | 是 | - | - |\n###### CloseSocketOptions 的属性值 @closesocketoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| code | number \\| null | 否 | 1000 | |\n| reason | string \\| null | 否 | \"\" | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n\n\n##### close 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[close](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-close)\n\n#### onOpen(callback) @onopen\n监听 WebSocket 连接打开事件\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketOpenCallbackResult](#onsocketopencallbackresult-values)) => void | 是 | - | - |\n###### OnSocketOpenCallbackResult 的属性值 @onsocketopencallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| header | any | 是 | - | 连接成功的 HTTP 响应 Header |\n\n\n##### onOpen 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[onOpen](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-onopen)\n\n#### onClose(callback) @onclose\n监听 WebSocket 连接关闭事件\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: any) => void | 是 | - | - |\n\n##### onClose 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[onClose](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-onclose)\n\n#### onError(callback) @onerror\n监听 WebSocket 错误\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [GeneralCallbackResult](#generalcallbackresult-values)) => void | 是 | - | - |\n\n##### onError 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[onError](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-onerror)\n\n#### onMessage(callback) @onmessage\n监听 WebSocket 接受到服务器的消息事件\n##### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketMessageCallbackResult](#onsocketmessagecallbackresult-values)) => void | 是 | - | - |\n###### OnSocketMessageCallbackResult 的属性值 @onsocketmessagecallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| data | any | 是 | - | 服务器返回的消息 |\n\n\n##### onMessage 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n\n\n##### 参见\n[onMessage](https://uniapp.dcloud.net.cn/api/request/socket-task.html#sockettask-onmessage)\n","compatibility":"### connectSocket 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[connectSocket](https://uniapp.dcloud.net.cn/api/request/websocket.html#connectsocket)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.connectSocket)\n"},"onSocketOpen":{"name":"## onSocketOpen(options) @onsocketopen","description":"监听WebSocket连接打开事件。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | (result: [OnSocketOpenCallbackResult](#onsocketopencallbackresult-values)) => void | 是 | - | - |","returnValue":"","compatibility":"### onSocketOpen 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[onSocketOpen](https://uniapp.dcloud.net.cn/api/request/websocket.html#onsocketopen)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.onSocketOpen)\n"},"onSocketError":{"name":"## onSocketError(callback) @onsocketerror","description":"下载文件资源到本地,客户端直接发起一个 HTTP GET 请求,返回文件的本地临时路径。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketErrorCallbackResult](#onsocketerrorcallbackresult-values)) => void | 是 | - | - |\n#### OnSocketErrorCallbackResult 的属性值 @onsocketerrorcallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| errMsg | string | 是 | - | 错误信息 |\n","returnValue":"","compatibility":"### onSocketError 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[onSocketError](https://uniapp.dcloud.net.cn/api/request/websocket.html#onsocketerror)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.onSocketError)\n"},"sendSocketMessage":{"name":"## sendSocketMessage(options) @sendsocketmessage","description":"通过 WebSocket 连接发送数据,需要先 uni.connectSocket,并在 uni.onSocketOpen 回调之后才能发送。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [SendSocketMessageOptions](#sendsocketmessageoptions-values) | 是 | - | - |\n#### SendSocketMessageOptions 的属性值 @sendsocketmessageoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| data | any | 是 | - | 需要发送的内容 |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"","compatibility":"### sendSocketMessage 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[sendSocketMessage](https://uniapp.dcloud.net.cn/api/request/websocket.html#sendsocketmessage)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.sendSocketMessage)\n"},"onSocketMessage":{"name":"## onSocketMessage(callback) @onsocketmessage","description":"监听WebSocket接受到服务器的消息事件。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketMessageCallbackResult](#onsocketmessagecallbackresult-values)) => void | 是 | - | - |\n#### OnSocketMessageCallbackResult 的属性值 @onsocketmessagecallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| data | any | 是 | - | 服务器返回的消息 |\n","returnValue":"","compatibility":"### onSocketMessage 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[onSocketMessage](https://uniapp.dcloud.net.cn/api/request/websocket.html#onsocketmessage)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.onSocketMessage)\n"},"closeSocket":{"name":"## closeSocket(options) @closesocket","description":"关闭 WebSocket 连接。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [CloseSocketOptions](#closesocketoptions-values) | 是 | - | - |\n#### CloseSocketOptions 的属性值 @closesocketoptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| code | number \\| null | 否 | 1000 | |\n| reason | string \\| null | 否 | \"\" | |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"","compatibility":"### closeSocket 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[closeSocket](https://uniapp.dcloud.net.cn/api/request/websocket.html#closesocket)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.closeSocket)\n"},"onSocketClose":{"name":"## onSocketClose(callback) @onsocketclose","description":"监听WebSocket关闭。","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| callback | (result: [OnSocketCloseCallbackResult](#onsocketclosecallbackresult-values)) => void | 是 | - | - |\n#### OnSocketCloseCallbackResult 的属性值 @onsocketclosecallbackresult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| code | number | 是 | - | 一个数字值表示关闭连接的状态号,表示连接被关闭的原因。\t |\n| reason | string | 是 | - | 一个可读的字符串,表示连接被关闭的原因。\t |\n","returnValue":"","compatibility":"### onSocketClose 兼容性 \n| Android 系统版本 | Android | iOS | web |\n| :- | :- | :- | :- |\n| 4.4 | 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[onSocketClose](https://uniapp.dcloud.net.cn/api/request/websocket.html#onsocketclose)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.network.websocket-global.onSocketClose)\n"},"websocket-global":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/websocket-global/websocket-global.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/websocket-global/websocket-global\n>Template\n```vue\n\r\n\r\n\r\n\r\n\n\n```\n>Script\n```uts\n\r\n export default {\r\n data() {\r\n return {\r\n connected: false,\r\n connecting: false,\r\n msg: '',\r\n roomId: '',\r\n platform: '',\r\n }\r\n },\r\n computed: {\r\n showMsg() : string {\r\n if (this.connected) {\r\n if (this.msg.length > 0) {\r\n return '收到消息:' + this.msg\r\n } else {\r\n return '等待接收消息'\r\n }\r\n } else {\r\n return '尚未连接'\r\n }\r\n },\r\n },\r\n onLoad() {\r\n this.platform = uni.getSystemInfoSync().platform\r\n },\r\n onUnload() {\r\n uni.closeSocket({\r\n code: 1000,\r\n reason: 'close reason from client',\r\n success: (res : any) => {\r\n console.log('uni.closeSocket success', res)\r\n },\r\n fail: (err : any) => {\r\n console.log('uni.closeSocket fail', err)\r\n },\r\n } as CloseSocketOptions)\r\n uni.hideLoading()\r\n },\r\n methods: {\r\n connect() {\r\n if (this.connected || this.connecting) {\r\n uni.showModal({\r\n content: '正在连接或者已经连接,请勿重复连接',\r\n showCancel: false,\r\n })\r\n return\r\n }\r\n this.connecting = true\r\n uni.showLoading({\r\n title: '连接中...',\r\n })\r\n uni.connectSocket({\r\n url: 'ws://websocket.dcloud.net.cn',\r\n header: null,\r\n protocols: null,\r\n success: (res : any) => {\r\n // 这里是接口调用成功的回调,不是连接成功的回调,请注意\r\n console.log('uni.connectSocket success', res)\r\n },\r\n fail: (err : any) => {\r\n // 这里是接口调用失败的回调,不是连接失败的回调,请注意\r\n console.log('uni.connectSocket fail', err)\r\n },\r\n })\r\n uni.onSocketOpen((res) => {\r\n this.connecting = false\r\n this.connected = true\r\n uni.hideLoading()\r\n\r\n uni.showToast({\r\n icon: 'none',\r\n title: '连接成功',\r\n })\r\n console.log('onOpen', res)\r\n })\r\n uni.onSocketError((err) => {\r\n this.connecting = false\r\n this.connected = false\r\n uni.hideLoading()\r\n\r\n uni.showModal({\r\n content: '连接失败,可能是websocket服务不可用,请稍后再试',\r\n showCancel: false,\r\n })\r\n console.log('onError', err)\r\n })\r\n uni.onSocketMessage((res) => {\r\n this.msg = res.data as string\r\n console.log('onMessage', res)\r\n })\r\n uni.onSocketClose((res) => {\r\n this.connected = false\r\n this.msg = ''\r\n console.log('onClose', res)\r\n })\r\n },\r\n send() {\r\n uni.sendSocketMessage({\r\n data:\r\n 'from ' +\r\n this.platform +\r\n ' : ' +\r\n parseInt((Math.random() * 10000).toString()).toString(),\r\n success: (res : any) => {\r\n console.log(res)\r\n },\r\n fail: (err : any) => {\r\n console.log(err)\r\n },\r\n } as SendSocketMessageOptions)\r\n },\r\n close() {\r\n uni.closeSocket({\r\n code: 1000,\r\n reason: 'close reason from client',\r\n success: (res : any) => {\r\n console.log('uni.closeSocket success', res)\r\n },\r\n fail: (err : any) => {\r\n console.log('uni.closeSocket fail', err)\r\n },\r\n } as CloseSocketOptions)\r\n },\r\n },\r\n }\r\n\n```\n\n:::"},"getSystemInfo":{"name":"## uni.getSystemInfo(options) @getsysteminfo","description":"异步获取系统信息","param":"### 参数 \n\n| 名称 | 类型 | 必填 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| options | [GetSystemInfoOptions](#getsysteminfooptions-values) | 是 | - | - |\n#### GetSystemInfoOptions 的属性值 @getsysteminfooptions-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| success | Function \\| null | 否 | null | |\n| fail | Function \\| null | 否 | null | |\n| complete | Function \\| null | 否 | null | |\n","returnValue":"","compatibility":"### getSystemInfo 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[getSystemInfo](http://uniapp.dcloud.io/api/system/info?id=getsysteminfo)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.get-system-info.getSystemInfo)\n"},"getSystemInfoSync":{"name":"## uni.getSystemInfoSync() @getsysteminfosync","description":"同步获取系统信息","param":"","returnValue":"### 返回值 \n\n| 类型 |\n| :- |\n| [GetSystemInfoResult](#getsysteminforesult-values) | \n\n#### GetSystemInfoResult 的属性值 @getsysteminforesult-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| SDKVersion | string | 是 | - | 客户端基础库版本 |\n| appId | string | 是 | - | `manifest.json` 中应用appid。 |\n| appLanguage | string | 是 | - | 应用设置的语言。 |\n| appName | string | 是 | - | `manifest.json` 中应用名称。 |\n| appVersion | string | 是 | - | `manifest.json` 中应用版本名称。 |\n| appVersionCode | string | 是 | - | `manifest.json` 中应用版本名号。 |\n| brand | string | 是 | - | 手机品牌。 |\n| browserName | string | 是 | - | 浏览器名称。`App` 端是系统 webview 的名字,比如 wkwebview、chrome。小程序端为空 |\n| browserVersion | string | 是 | - | 浏览器版本、webview 版本。 |\n| deviceId | string | 是 | - | 设备 ID |\n| deviceBrand | string | 是 | - | 设备品牌。如:`apple`、`huawei`。 |\n| deviceModel | string | 是 | - | 设备型号 |\n| deviceType | \"phone\" \\| \"pad\" \\| \"tv\" \\| \"watch\" \\| \"pc\" \\| \"null\" \\| \"car\" \\| \"vr\" \\| \"appliance\" | 是 | - | 设备类型。 |\n| devicePixelRatio | number | 是 | - | 设备像素比 |\n| deviceOrientation | \"portrait\" \\| \"landscape\" | 是 | - | 设备方向。 |\n| language | string | 是 | - | 程序设置的语言 |\n| model | string | 是 | - | 手机型号 |\n| osName | \"ios\" \\| \"android\" \\| \"mac\" \\| \"windows\" \\| \"linux\" | 是 | - | 系统名称\t |\n| osVersion | string | 是 | - | 操作系统版本。如 ios 版本,andriod 版本 |\n| osLanguage | string | 是 | - | 操作系统语言 |\n| osTheme | \"light\" \\| \"dark\" | 否 | - | 操作系统主题
|\n| pixelRatio | number | 是 | - | 设备像素比 |\n| platform | \"ios\" \\| \"android\" \\| \"mac\" \\| \"windows\" \\| \"linux\" | 是 | - | 客户端平台 |\n| screenWidth | number | 是 | - | 屏幕宽度 |\n| screenHeight | number | 是 | - | 屏幕高度 |\n| statusBarHeight | number | 是 | - | 状态栏的高度 |\n| system | string | 是 | - | 操作系统版本 |\n| safeArea | [SafeArea](#safearea-values) | 是 | - | 在竖屏正方向下的安全区域 |\n| safeAreaInsets | [SafeAreaInsets](#safeareainsets-values) | 是 | - | 在竖屏正方向下的安全区域插入位置 |\n| ua | string | 是 | - | 用户标识。小程序端为空 |\n| ~~uniCompileVersion~~ | string | 是 | - | uni 编译器版本\n已废弃,仅为了向下兼容保留 |\n| uniCompilerVersion | string | 是 | - | uni 编译器版本 |\n| uniPlatform | \"app\" \\| \"web\" \\| \"mp-weixin\" \\| \"mp-alipay\" \\| \"mp-baidu\" \\| \"mp-toutiao\" \\| \"mp-lark\" \\| \"mp-qq\" \\| \"mp-kuaishou\" \\| \"mp-jd\" \\| \"mp-360\" \\| \"quickapp-webview\" \\| \"quickapp-webview-union\" \\| \"quickapp-webview-huawei\" | 是 | - | uni-app 运行平台。 |\n| uniRuntimeVersion | string | 是 | - | uni 运行时版本 |\n| ~~uniCompileVersionCode~~ | number | 是 | - | uni 编译器版本号\n已废弃,仅为了向下兼容保留 |\n| uniCompilerVersionCode | number | 是 | - | uni 编译器版本号 |\n| uniRuntimeVersionCode | number | 是 | - | uni 运行时版本号 |\n| ~~version~~ | string | 是 | - | 引擎版本号。已废弃,仅为了向下兼容保留 \n已废弃,仅为了向下兼容保留 |\n| romName | string | 是 | - | rom 名称。Android 部分机型获取不到值。iOS 恒为 `ios` |\n| romVersion | string | 是 | - | rom 版本号。Android 部分机型获取不到值。iOS 恒为 `ios 版本号` |\n| windowWidth | number | 是 | - | 可使用窗口宽度 |\n| windowHeight | number | 是 | - | 可使用窗口高度 |\n| windowTop | number | 是 | - | 可使用窗口的顶部位置 |\n| windowBottom | number | 是 | - | 可使用窗口的底部位置 |\n| osAndroidAPILevel | number \\| null | 否 | - | |\n\n##### SafeArea 的属性值 @safearea-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| left | number | 是 | - | 安全区域左上角横坐标 |\n| right | number | 是 | - | 安全区域右下角横坐标 |\n| top | number | 是 | - | 安全区域左上角纵坐标 |\n| bottom | number | 是 | - | 安全区域右下角纵坐标 |\n| width | number | 是 | - | 安全区域的宽度,单位逻辑像素 |\n| height | number | 是 | - | 安全区域的高度,单位逻辑像素 |\n\n##### SafeAreaInsets 的属性值 @safeareainsets-values \n\n| 名称 | 类型 | 必备 | 默认值 | 描述 |\n| :- | :- | :- | :- | :- |\n| left | number | 是 | - | 安全区域左侧插入位置 |\n| right | number | 是 | - | 安全区域右侧插入位置 |\n| top | number | 是 | - | 安全区顶部插入位置 |\n| bottom | number | 是 | - | 安全区域底部插入位置 |\n\n##### GetSystemInfoResult 兼容性 \n| | Android | iOS | web |\n| :- | :- | :- | :- |\n| osTheme | √ | x | - |\n| osAndroidAPILevel | √ | x | - |\n","compatibility":"### getSystemInfoSync 兼容性 \n| Android | iOS | web |\n| :- | :- | :- |\n| 3.9 | x | 4.0 |\n","tutorial":"\n### 参见\n[getSystemInfoSync](http://uniapp.dcloud.io/api/system/info?id=getsysteminfosync)\n\n[相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.get-system-info.getSystemInfoSync)\n"},"get-system-info":{"example":"## 示例 \n> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/get-system-info/get-system-info.uvue) \n ::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/get-system-info/get-system-info\n>Template\n```vue\n