提交 cdc1204b 编写于 作者: D DCloud_LXH

chore: uni-app-x api

上级 13fb70e3
...@@ -129,8 +129,9 @@ ...@@ -129,8 +129,9 @@
* [removeStorageSync](api/removeStorageSync.md) * [removeStorageSync](api/removeStorageSync.md)
* [clearStorage](api/clearStorage.md) * [clearStorage](api/clearStorage.md)
* [clearStorageSync](api/clearStorageSync.md) * [clearStorageSync](api/clearStorageSync.md)
* 组件 * 组件上下文对象
* [web-view组件上下文对象](api/createWebviewContext.md) * [web-view组件上下文对象](api/createWebviewContext.md)
* [video组件上下文对象](api/createVideoContext.md)
* [uniCloud客户端API](unicloud.md) * [uniCloud客户端API](unicloud.md)
* CSS * CSS
* [CSS概述](css/README.md) * [CSS概述](css/README.md)
......
## uni.$emit(eventName, args) @$emit
<!-- UTSAPIJSON.$emit.description -->
<!-- UTSAPIJSON.$emit.param -->
<!-- UTSAPIJSON.$emit.returnValue -->
<!-- UTSAPIJSON.$emit.compatibility -->
<!-- UTSAPIJSON.$emit.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.$off(eventName, callback) @$off
<!-- UTSAPIJSON.$off.description -->
<!-- UTSAPIJSON.$off.param -->
<!-- UTSAPIJSON.$off.returnValue -->
<!-- UTSAPIJSON.$off.compatibility -->
<!-- UTSAPIJSON.$off.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.$on(eventName, callback) @$on
<!-- UTSAPIJSON.$on.description -->
<!-- UTSAPIJSON.$on.param -->
<!-- UTSAPIJSON.$on.returnValue -->
<!-- UTSAPIJSON.$on.compatibility -->
<!-- UTSAPIJSON.$on.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.$once(eventName, callback) @$once
<!-- UTSAPIJSON.$once.description -->
<!-- UTSAPIJSON.$once.param -->
<!-- UTSAPIJSON.$once.returnValue -->
<!-- UTSAPIJSON.$once.compatibility -->
<!-- UTSAPIJSON.$once.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.chooseImage(options) @chooseimage
<!-- UTSAPIJSON.chooseImage.description -->
<!-- UTSAPIJSON.chooseImage.param -->
<!-- UTSAPIJSON.chooseImage.returnValue -->
<!-- UTSAPIJSON.chooseImage.compatibility -->
<!-- UTSAPIJSON.chooseImage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.clearStorage(option?) @clearstorage
<!-- UTSAPIJSON.clearStorage.description -->
<!-- UTSAPIJSON.clearStorage.param -->
<!-- UTSAPIJSON.clearStorage.returnValue -->
<!-- UTSAPIJSON.clearStorage.compatibility -->
<!-- UTSAPIJSON.clearStorage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.clearStorageSync() @clearstoragesync
<!-- UTSAPIJSON.clearStorageSync.description -->
<!-- UTSAPIJSON.clearStorageSync.param -->
<!-- UTSAPIJSON.clearStorageSync.returnValue -->
<!-- UTSAPIJSON.clearStorageSync.compatibility -->
<!-- UTSAPIJSON.clearStorageSync.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.closePreviewImage(options) @closepreviewimage
<!-- UTSAPIJSON.closePreviewImage.description -->
<!-- UTSAPIJSON.closePreviewImage.param -->
<!-- UTSAPIJSON.closePreviewImage.returnValue -->
<!-- UTSAPIJSON.closePreviewImage.compatibility -->
<!-- UTSAPIJSON.closePreviewImage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.closeSocket(options) @closesocket
<!-- UTSAPIJSON.closeSocket.description -->
<!-- UTSAPIJSON.closeSocket.param -->
<!-- UTSAPIJSON.closeSocket.returnValue -->
<!-- UTSAPIJSON.closeSocket.compatibility -->
<!-- UTSAPIJSON.closeSocket.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.connectSocket(options) @connectsocket
<!-- UTSAPIJSON.connectSocket.description -->
<!-- UTSAPIJSON.connectSocket.param -->
<!-- UTSAPIJSON.connectSocket.returnValue -->
<!-- UTSAPIJSON.connectSocket.compatibility -->
<!-- UTSAPIJSON.connectSocket.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.createSelectorQuery() @createselectorquery
<!-- UTSAPIJSON.createSelectorQuery.description -->
<!-- UTSAPIJSON.createSelectorQuery.param -->
<!-- UTSAPIJSON.createSelectorQuery.returnValue -->
<!-- UTSAPIJSON.createSelectorQuery.compatibility -->
<!-- UTSAPIJSON.createSelectorQuery.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.createVideoContext(videoId, currentComponent) @createvideocontext
<!-- UTSAPIJSON.createVideoContext.description -->
<!-- UTSAPIJSON.createVideoContext.param -->
<!-- UTSAPIJSON.createVideoContext.returnValue -->
<!-- UTSAPIJSON.createVideoContext.compatibility -->
<!-- UTSAPIJSON.createVideoContext.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.$on(eventName, callback) @$on
<!-- UTSAPIJSON.event-bus.description -->
<!-- UTSAPIJSON.event-bus.param -->
<!-- UTSAPIJSON.event-bus.returnValue -->
<!-- UTSAPIJSON.event-bus.compatibility -->
<!-- UTSAPIJSON.event-bus.tutorial -->
## uni.$off(eventName, callback) @$off
<!-- UTSAPIJSON.event-bus.description -->
<!-- UTSAPIJSON.event-bus.param -->
<!-- UTSAPIJSON.event-bus.returnValue -->
<!-- UTSAPIJSON.event-bus.compatibility -->
<!-- UTSAPIJSON.event-bus.tutorial -->
## uni.$once(eventName, callback) @$once
<!-- UTSAPIJSON.event-bus.description -->
<!-- UTSAPIJSON.event-bus.param -->
<!-- UTSAPIJSON.event-bus.returnValue -->
<!-- UTSAPIJSON.event-bus.compatibility -->
<!-- UTSAPIJSON.event-bus.tutorial -->
## uni.$emit(eventName, args) @$emit
<!-- UTSAPIJSON.event-bus.description -->
<!-- UTSAPIJSON.event-bus.param -->
<!-- UTSAPIJSON.event-bus.returnValue -->
<!-- UTSAPIJSON.event-bus.compatibility -->
<!-- UTSAPIJSON.event-bus.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
<!-- UTSAPIJSON.exit.description --> <!-- UTSAPIJSON.exit.description -->
**注意**
- HBuilderX3.8.15+ 新增支持
- 小程序端必须有点击行为才能调用成功
- App-iOS平台可以调用此API,但不支持退出应用功能,触发fail回调返回system not support错误
<!-- UTSAPIJSON.exit.param --> <!-- UTSAPIJSON.exit.param -->
<!-- UTSAPIJSON.exit.returnValue --> <!-- UTSAPIJSON.exit.returnValue -->
...@@ -15,26 +10,6 @@ ...@@ -15,26 +10,6 @@
<!-- UTSAPIJSON.exit.tutorial --> <!-- UTSAPIJSON.exit.tutorial -->
### 示例
```javascript
// 退出应用
uni.exit({
success: () => {
console.log("exit success")
},
fail: (e) => {
console.log("exit fail")
}
});
```
### 错误码
|错误码 |错误信息 |说明 |
|--- |---- |------ |
|12001 |system not support |当前系统不支持相关能力 |
<!-- UTSAPIJSON.general_type.name --> <!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param --> <!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
...@@ -8,26 +8,6 @@ ...@@ -8,26 +8,6 @@
<!-- UTSAPIJSON.getLocation.compatibility --> <!-- UTSAPIJSON.getLocation.compatibility -->
### 注意
uni-app x的定位,默认是系统定位,system。
system的定位仅支持wgs84坐标系、不支持逆地址解析、且某些老型号国产Android机因gms问题不支持系统定位。
如需更强的定位能力,需加载专业定位sdk。
真机运行基座不包含三方定位sdk。
三方定位sdk方面,暂不支持高德、百度,但支持腾讯定位。
可下载[腾讯定位插件](https://ext.dcloud.net.cn/plugin?id=14569),在插件中配置key打包后生效。
上述腾讯定位插件属于[ext api插件](../../api/extapi.md),引用到工程后,会覆盖uni.getLocation的实现,替换掉系统定位。
如需其他定位,请在插件市场搜索定位相关的uts插件。
不管系统定位、还是三方sdk定位,都有很多注意事项,包括gms、坐标系、隐私和权限等,请仔细阅读下面的参考链接。
<!-- UTSAPIJSON.getLocation.tutorial --> <!-- UTSAPIJSON.getLocation.tutorial -->
<!-- UTSAPIJSON.general_type.name --> <!-- UTSAPIJSON.general_type.name -->
......
## uni.getStorage(options) @getstorage
<!-- UTSAPIJSON.getStorage.description -->
<!-- UTSAPIJSON.getStorage.param -->
<!-- UTSAPIJSON.getStorage.returnValue -->
<!-- UTSAPIJSON.getStorage.compatibility -->
<!-- UTSAPIJSON.getStorage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.getStorageInfo(options) @getstorageinfo
<!-- UTSAPIJSON.getStorageInfo.description -->
<!-- UTSAPIJSON.getStorageInfo.param -->
<!-- UTSAPIJSON.getStorageInfo.returnValue -->
<!-- UTSAPIJSON.getStorageInfo.compatibility -->
<!-- UTSAPIJSON.getStorageInfo.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.getStorageInfoSync() @getstorageinfosync
<!-- UTSAPIJSON.getStorageInfoSync.description -->
<!-- UTSAPIJSON.getStorageInfoSync.param -->
<!-- UTSAPIJSON.getStorageInfoSync.returnValue -->
<!-- UTSAPIJSON.getStorageInfoSync.compatibility -->
<!-- UTSAPIJSON.getStorageInfoSync.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.getStorageSync(key) @getstoragesync
<!-- UTSAPIJSON.getStorageSync.description -->
<!-- UTSAPIJSON.getStorageSync.param -->
<!-- UTSAPIJSON.getStorageSync.returnValue -->
<!-- UTSAPIJSON.getStorageSync.compatibility -->
<!-- UTSAPIJSON.getStorageSync.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
...@@ -2,18 +2,6 @@ ...@@ -2,18 +2,6 @@
<!-- UTSAPIJSON.getSystemInfo.description --> <!-- UTSAPIJSON.getSystemInfo.description -->
uni-app 提供了异步(`uni.getSystemInfo`)和同步(`uni.getSystemInfoSync`)的2个API获取系统信息。
按照运行环境层级排序,从底层向上,systemInfo有6个概念:
- `device`:运行应用的设备,如iphone、huawei
- `os`:设备的操作系统,如 ios、andriod、windows、mac、linux
- `rom`:基于操作系统的定制,Android系统特有概念,如miui、鸿蒙
- `host`:运行应用的宿主程序,即OS和应用之间的运行环境,如浏览器、微信等小程序宿主、集成uniMPSDK的App。uni-app直接开发的app没有host概念
- `uni`:uni-app框架相关的信息,如uni-app框架的编译器版本、运行时版本
- `app`:开发者的应用相关的信息,如应用名称、版本
[详见](https://uniapp.dcloud.net.cn/api/system/info.html#getsysteminfo)
<!-- UTSAPIJSON.getSystemInfo.param --> <!-- UTSAPIJSON.getSystemInfo.param -->
<!-- UTSAPIJSON.getSystemInfo.returnValue --> <!-- UTSAPIJSON.getSystemInfo.returnValue -->
......
## uni.hideTabBar(options?) @hidetabbar
<!-- UTSAPIJSON.hideTabBar.description -->
<!-- UTSAPIJSON.hideTabBar.param -->
<!-- UTSAPIJSON.hideTabBar.returnValue -->
<!-- UTSAPIJSON.hideTabBar.compatibility -->
<!-- UTSAPIJSON.hideTabBar.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.hideTabBarRedDot(options) @hidetabbarreddot
<!-- UTSAPIJSON.hideTabBarRedDot.description -->
<!-- UTSAPIJSON.hideTabBarRedDot.param -->
<!-- UTSAPIJSON.hideTabBarRedDot.returnValue -->
<!-- UTSAPIJSON.hideTabBarRedDot.compatibility -->
<!-- UTSAPIJSON.hideTabBarRedDot.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.showModal(options) @showmodal
<!-- UTSAPIJSON.modal.description -->
<!-- UTSAPIJSON.modal.param -->
<!-- UTSAPIJSON.modal.returnValue -->
<!-- UTSAPIJSON.modal.compatibility -->
<!-- UTSAPIJSON.modal.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.navigateBack(options?) @navigateback
<!-- UTSAPIJSON.navigateBack.description -->
<!-- UTSAPIJSON.navigateBack.param -->
<!-- UTSAPIJSON.navigateBack.returnValue -->
<!-- UTSAPIJSON.navigateBack.compatibility -->
<!-- UTSAPIJSON.navigateBack.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.navigateTo(options) @navigateto
<!-- UTSAPIJSON.navigateTo.description -->
<!-- UTSAPIJSON.navigateTo.param -->
<!-- UTSAPIJSON.navigateTo.returnValue -->
<!-- UTSAPIJSON.navigateTo.compatibility -->
<!-- UTSAPIJSON.navigateTo.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.navigateTo(options) @navigateto
<!-- UTSAPIJSON.navigator.description -->
<!-- UTSAPIJSON.navigator.param -->
<!-- UTSAPIJSON.navigator.returnValue -->
<!-- UTSAPIJSON.navigator.compatibility -->
<!-- UTSAPIJSON.navigator.tutorial -->
## uni.redirectTo(options) @redirectto
<!-- UTSAPIJSON.navigator.description -->
<!-- UTSAPIJSON.navigator.param -->
<!-- UTSAPIJSON.navigator.returnValue -->
<!-- UTSAPIJSON.navigator.compatibility -->
<!-- UTSAPIJSON.navigator.tutorial -->
## uni.reLaunch(options) @relaunch
<!-- UTSAPIJSON.navigator.description -->
<!-- UTSAPIJSON.navigator.param -->
<!-- UTSAPIJSON.navigator.returnValue -->
<!-- UTSAPIJSON.navigator.compatibility -->
<!-- UTSAPIJSON.navigator.tutorial -->
## uni.switchTab(options) @switchtab
<!-- UTSAPIJSON.navigator.description -->
<!-- UTSAPIJSON.navigator.param -->
<!-- UTSAPIJSON.navigator.returnValue -->
<!-- UTSAPIJSON.navigator.compatibility -->
<!-- UTSAPIJSON.navigator.tutorial -->
## uni.navigateBack(options?) @navigateback
<!-- UTSAPIJSON.navigator.description -->
<!-- UTSAPIJSON.navigator.param -->
<!-- UTSAPIJSON.navigator.returnValue -->
<!-- UTSAPIJSON.navigator.compatibility -->
<!-- UTSAPIJSON.navigator.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.createSelectorQuery() @createselectorquery
<!-- UTSAPIJSON.nodes-info.description -->
<!-- UTSAPIJSON.nodes-info.param -->
<!-- UTSAPIJSON.nodes-info.returnValue -->
<!-- UTSAPIJSON.nodes-info.compatibility -->
<!-- UTSAPIJSON.nodes-info.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.onSocketClose(callback) @onsocketclose
<!-- UTSAPIJSON.onSocketClose.description -->
<!-- UTSAPIJSON.onSocketClose.param -->
<!-- UTSAPIJSON.onSocketClose.returnValue -->
<!-- UTSAPIJSON.onSocketClose.compatibility -->
<!-- UTSAPIJSON.onSocketClose.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.onSocketError(callback) @onsocketerror
<!-- UTSAPIJSON.onSocketError.description -->
<!-- UTSAPIJSON.onSocketError.param -->
<!-- UTSAPIJSON.onSocketError.returnValue -->
<!-- UTSAPIJSON.onSocketError.compatibility -->
<!-- UTSAPIJSON.onSocketError.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.onSocketMessage(callback) @onsocketmessage
<!-- UTSAPIJSON.onSocketMessage.description -->
<!-- UTSAPIJSON.onSocketMessage.param -->
<!-- UTSAPIJSON.onSocketMessage.returnValue -->
<!-- UTSAPIJSON.onSocketMessage.compatibility -->
<!-- UTSAPIJSON.onSocketMessage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.onSocketOpen(options) @onsocketopen
<!-- UTSAPIJSON.onSocketOpen.description -->
<!-- UTSAPIJSON.onSocketOpen.param -->
<!-- UTSAPIJSON.onSocketOpen.returnValue -->
<!-- UTSAPIJSON.onSocketOpen.compatibility -->
<!-- UTSAPIJSON.onSocketOpen.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.chooseImage(options) @chooseimage
<!-- UTSAPIJSON.preview-image.description -->
<!-- UTSAPIJSON.preview-image.param -->
<!-- UTSAPIJSON.preview-image.returnValue -->
<!-- UTSAPIJSON.preview-image.compatibility -->
<!-- UTSAPIJSON.preview-image.tutorial -->
## uni.previewImage(options) @previewimage
<!-- UTSAPIJSON.preview-image.description -->
<!-- UTSAPIJSON.preview-image.param -->
<!-- UTSAPIJSON.preview-image.returnValue -->
<!-- UTSAPIJSON.preview-image.compatibility -->
<!-- UTSAPIJSON.preview-image.tutorial -->
## uni.closePreviewImage(options) @closepreviewimage
<!-- UTSAPIJSON.preview-image.description -->
<!-- UTSAPIJSON.preview-image.param -->
<!-- UTSAPIJSON.preview-image.returnValue -->
<!-- UTSAPIJSON.preview-image.compatibility -->
<!-- UTSAPIJSON.preview-image.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.previewImage(options) @previewimage
<!-- UTSAPIJSON.previewImage.description -->
<!-- UTSAPIJSON.previewImage.param -->
<!-- UTSAPIJSON.previewImage.returnValue -->
<!-- UTSAPIJSON.previewImage.compatibility -->
<!-- UTSAPIJSON.previewImage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.stopPullDownRefresh() @stoppulldownrefresh
<!-- UTSAPIJSON.pull-down-refresh.description -->
<!-- UTSAPIJSON.pull-down-refresh.param -->
<!-- UTSAPIJSON.pull-down-refresh.returnValue -->
<!-- UTSAPIJSON.pull-down-refresh.compatibility -->
<!-- UTSAPIJSON.pull-down-refresh.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.reLaunch(options) @relaunch
<!-- UTSAPIJSON.reLaunch.description -->
<!-- UTSAPIJSON.reLaunch.param -->
<!-- UTSAPIJSON.reLaunch.returnValue -->
<!-- UTSAPIJSON.reLaunch.compatibility -->
<!-- UTSAPIJSON.reLaunch.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
# API概述
uni-app x项目的uts代码中可以使用很多API。包括:
- uts的api [详见](../../uts/buildin-object-api/global.md)
- 全局api,前面不需要加`uni.`。如`getApp`
- uni.xxx的内置api。见左侧
- uniCloud.xxx的内置api。见左侧
- dom的api [详见](dom/README.md)
- vue的api [详见](../../tutorial/vue3-api.md)
- 原生api
由于uts可以直接调用Android和iOS的api,所以os和三方sdk的能力都可以在uts中调用。如下:
```vue
<script>
import Build from 'android.os.Build';
export default {
onLoad() {
console.log(Build.MODEL); //调用原生对象,返回手机型号
console.log(uni.getSystemInfoSync().deviceModel); //调用uni API,返回手机型号。与上一行返回值相同
}
}
</script>
```
上面的示例,在页面启动时打印了2行日志,显示手机型号。
- uni.getSystemInfoSync,是uni的api
- import的Build,是Android os的api
可以看出,在uni-app x里,可以直接调用os的能力,不受限制,语法是uts的语法,但需要了解什么功能在原生里是哪个api。
使用`uni.getSystemInfoSync`则比较简单,看uni的文档即可,且可跨平台。
其实,`uni.getSystemInfoSync`的内部实现就是一个uts模块,底层使用了一样的代码。
大多数uni.的api,都是uts开发的,它们会陆续开源在[uni-api](https://gitcode.net/dcloud/uni-api)
插件市场也有很多做好的uts插件,方便开发者拿来即用。[uts插件](https://ext.dcloud.net.cn/?cat1=8&type=UpdatedDate)
虽然上述页面可以直接调用原生能力,但一般原生能力建议封装为[uni_modules](../../plugin/uni_modules.md)形式的[uts插件](../../plugin/uts-plugin.md)。这样方便共享、方便跨平台。
\ No newline at end of file
## uni.redirectTo(options) @redirectto
<!-- UTSAPIJSON.redirectTo.description -->
<!-- UTSAPIJSON.redirectTo.param -->
<!-- UTSAPIJSON.redirectTo.returnValue -->
<!-- UTSAPIJSON.redirectTo.compatibility -->
<!-- UTSAPIJSON.redirectTo.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.removeStorage(options) @removestorage
<!-- UTSAPIJSON.removeStorage.description -->
<!-- UTSAPIJSON.removeStorage.param -->
<!-- UTSAPIJSON.removeStorage.returnValue -->
<!-- UTSAPIJSON.removeStorage.compatibility -->
<!-- UTSAPIJSON.removeStorage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.removeStorageSync(key) @removestoragesync
<!-- UTSAPIJSON.removeStorageSync.description -->
<!-- UTSAPIJSON.removeStorageSync.param -->
<!-- UTSAPIJSON.removeStorageSync.returnValue -->
<!-- UTSAPIJSON.removeStorageSync.compatibility -->
<!-- UTSAPIJSON.removeStorageSync.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.removeTabBarBadge(options) @removetabbarbadge
<!-- UTSAPIJSON.removeTabBarBadge.description -->
<!-- UTSAPIJSON.removeTabBarBadge.param -->
<!-- UTSAPIJSON.removeTabBarBadge.returnValue -->
<!-- UTSAPIJSON.removeTabBarBadge.compatibility -->
<!-- UTSAPIJSON.removeTabBarBadge.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
<!-- UTSAPIJSON.request.description --> <!-- UTSAPIJSON.request.description -->
request方法支持泛型,可将服务器的json数据转为自定义的type。
由于json在强类型语言中无法像js那样使用,如果您不熟悉ts中type+泛型来格式化服务器返回的数据,那么需要点这里阅读[request的教程](../tutorial/request.md)
<!-- UTSAPIJSON.request.param --> <!-- UTSAPIJSON.request.param -->
<!-- UTSAPIJSON.request.returnValue --> <!-- UTSAPIJSON.request.returnValue -->
...@@ -16,7 +12,4 @@ request方法支持泛型,可将服务器的json数据转为自定义的type ...@@ -16,7 +12,4 @@ request方法支持泛型,可将服务器的json数据转为自定义的type
<!-- UTSAPIJSON.general_type.name --> <!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param --> <!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## tips
- uts中暂不支持arraybuffer
\ No newline at end of file
## uni.sendSocketMessage(options) @sendsocketmessage
<!-- UTSAPIJSON.sendSocketMessage.description -->
<!-- UTSAPIJSON.sendSocketMessage.param -->
<!-- UTSAPIJSON.sendSocketMessage.returnValue -->
<!-- UTSAPIJSON.sendSocketMessage.compatibility -->
<!-- UTSAPIJSON.sendSocketMessage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.setTabBarBadge(options) @settabbarbadge
<!-- UTSAPIJSON.set-tabbar.description -->
<!-- UTSAPIJSON.set-tabbar.param -->
<!-- UTSAPIJSON.set-tabbar.returnValue -->
<!-- UTSAPIJSON.set-tabbar.compatibility -->
<!-- UTSAPIJSON.set-tabbar.tutorial -->
## uni.removeTabBarBadge(options) @removetabbarbadge
<!-- UTSAPIJSON.set-tabbar.description -->
<!-- UTSAPIJSON.set-tabbar.param -->
<!-- UTSAPIJSON.set-tabbar.returnValue -->
<!-- UTSAPIJSON.set-tabbar.compatibility -->
<!-- UTSAPIJSON.set-tabbar.tutorial -->
## uni.setTabBarItem(options) @settabbaritem
<!-- UTSAPIJSON.set-tabbar.description -->
<!-- UTSAPIJSON.set-tabbar.param -->
<!-- UTSAPIJSON.set-tabbar.returnValue -->
<!-- UTSAPIJSON.set-tabbar.compatibility -->
<!-- UTSAPIJSON.set-tabbar.tutorial -->
## uni.setTabBarStyle(options) @settabbarstyle
<!-- UTSAPIJSON.set-tabbar.description -->
<!-- UTSAPIJSON.set-tabbar.param -->
<!-- UTSAPIJSON.set-tabbar.returnValue -->
<!-- UTSAPIJSON.set-tabbar.compatibility -->
<!-- UTSAPIJSON.set-tabbar.tutorial -->
## uni.hideTabBar(options?) @hidetabbar
<!-- UTSAPIJSON.set-tabbar.description -->
<!-- UTSAPIJSON.set-tabbar.param -->
<!-- UTSAPIJSON.set-tabbar.returnValue -->
<!-- UTSAPIJSON.set-tabbar.compatibility -->
<!-- UTSAPIJSON.set-tabbar.tutorial -->
## uni.showTabBar(options?) @showtabbar
<!-- UTSAPIJSON.set-tabbar.description -->
<!-- UTSAPIJSON.set-tabbar.param -->
<!-- UTSAPIJSON.set-tabbar.returnValue -->
<!-- UTSAPIJSON.set-tabbar.compatibility -->
<!-- UTSAPIJSON.set-tabbar.tutorial -->
## uni.showTabBarRedDot(options) @showtabbarreddot
<!-- UTSAPIJSON.set-tabbar.description -->
<!-- UTSAPIJSON.set-tabbar.param -->
<!-- UTSAPIJSON.set-tabbar.returnValue -->
<!-- UTSAPIJSON.set-tabbar.compatibility -->
<!-- UTSAPIJSON.set-tabbar.tutorial -->
## uni.hideTabBarRedDot(options) @hidetabbarreddot
<!-- UTSAPIJSON.set-tabbar.description -->
<!-- UTSAPIJSON.set-tabbar.param -->
<!-- UTSAPIJSON.set-tabbar.returnValue -->
<!-- UTSAPIJSON.set-tabbar.compatibility -->
<!-- UTSAPIJSON.set-tabbar.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.setStorage(options) @setstorage
<!-- UTSAPIJSON.setStorage.description -->
<!-- UTSAPIJSON.setStorage.param -->
<!-- UTSAPIJSON.setStorage.returnValue -->
<!-- UTSAPIJSON.setStorage.compatibility -->
<!-- UTSAPIJSON.setStorage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.setStorageSync(key, data) @setstoragesync
<!-- UTSAPIJSON.setStorageSync.description -->
<!-- UTSAPIJSON.setStorageSync.param -->
<!-- UTSAPIJSON.setStorageSync.returnValue -->
<!-- UTSAPIJSON.setStorageSync.compatibility -->
<!-- UTSAPIJSON.setStorageSync.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.setTabBarBadge(options) @settabbarbadge
<!-- UTSAPIJSON.setTabBarBadge.description -->
<!-- UTSAPIJSON.setTabBarBadge.param -->
<!-- UTSAPIJSON.setTabBarBadge.returnValue -->
<!-- UTSAPIJSON.setTabBarBadge.compatibility -->
<!-- UTSAPIJSON.setTabBarBadge.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.setTabBarItem(options) @settabbaritem
<!-- UTSAPIJSON.setTabBarItem.description -->
<!-- UTSAPIJSON.setTabBarItem.param -->
<!-- UTSAPIJSON.setTabBarItem.returnValue -->
<!-- UTSAPIJSON.setTabBarItem.compatibility -->
<!-- UTSAPIJSON.setTabBarItem.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.setTabBarStyle(options) @settabbarstyle
<!-- UTSAPIJSON.setTabBarStyle.description -->
<!-- UTSAPIJSON.setTabBarStyle.param -->
<!-- UTSAPIJSON.setTabBarStyle.returnValue -->
<!-- UTSAPIJSON.setTabBarStyle.compatibility -->
<!-- UTSAPIJSON.setTabBarStyle.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.showModal(options) @showmodal
<!-- UTSAPIJSON.showModal.description -->
<!-- UTSAPIJSON.showModal.param -->
<!-- UTSAPIJSON.showModal.returnValue -->
<!-- UTSAPIJSON.showModal.compatibility -->
<!-- UTSAPIJSON.showModal.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.showTabBar(options?) @showtabbar
<!-- UTSAPIJSON.showTabBar.description -->
<!-- UTSAPIJSON.showTabBar.param -->
<!-- UTSAPIJSON.showTabBar.returnValue -->
<!-- UTSAPIJSON.showTabBar.compatibility -->
<!-- UTSAPIJSON.showTabBar.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.showTabBarRedDot(options) @showtabbarreddot
<!-- UTSAPIJSON.showTabBarRedDot.description -->
<!-- UTSAPIJSON.showTabBarRedDot.param -->
<!-- UTSAPIJSON.showTabBarRedDot.returnValue -->
<!-- UTSAPIJSON.showTabBarRedDot.compatibility -->
<!-- UTSAPIJSON.showTabBarRedDot.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.showToast(options) @showtoast
<!-- UTSAPIJSON.showToast.description -->
<!-- UTSAPIJSON.showToast.param -->
<!-- UTSAPIJSON.showToast.returnValue -->
<!-- UTSAPIJSON.showToast.compatibility -->
<!-- UTSAPIJSON.showToast.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.stopPullDownRefresh() @stoppulldownrefresh
<!-- UTSAPIJSON.stopPullDownRefresh.description -->
<!-- UTSAPIJSON.stopPullDownRefresh.param -->
<!-- UTSAPIJSON.stopPullDownRefresh.returnValue -->
<!-- UTSAPIJSON.stopPullDownRefresh.compatibility -->
<!-- UTSAPIJSON.stopPullDownRefresh.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.setStorage(options) @setstorage
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.setStorageSync(key, data) @setstoragesync
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.getStorage(options) @getstorage
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.getStorageSync(key) @getstoragesync
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.getStorageInfo(options) @getstorageinfo
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.getStorageInfoSync() @getstorageinfosync
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.removeStorage(options) @removestorage
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.removeStorageSync(key) @removestoragesync
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.clearStorage(option?) @clearstorage
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
## uni.clearStorageSync() @clearstoragesync
<!-- UTSAPIJSON.storage.description -->
<!-- UTSAPIJSON.storage.param -->
<!-- UTSAPIJSON.storage.returnValue -->
<!-- UTSAPIJSON.storage.compatibility -->
<!-- UTSAPIJSON.storage.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.switchTab(options) @switchtab
<!-- UTSAPIJSON.switchTab.description -->
<!-- UTSAPIJSON.switchTab.param -->
<!-- UTSAPIJSON.switchTab.returnValue -->
<!-- UTSAPIJSON.switchTab.compatibility -->
<!-- UTSAPIJSON.switchTab.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.showToast(options) @showtoast
<!-- UTSAPIJSON.toast.description -->
<!-- UTSAPIJSON.toast.param -->
<!-- UTSAPIJSON.toast.returnValue -->
<!-- UTSAPIJSON.toast.compatibility -->
<!-- UTSAPIJSON.toast.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
## uni.connectSocket(options) @connectsocket
<!-- UTSAPIJSON.websocket-global.description -->
<!-- UTSAPIJSON.websocket-global.param -->
<!-- UTSAPIJSON.websocket-global.returnValue -->
<!-- UTSAPIJSON.websocket-global.compatibility -->
<!-- UTSAPIJSON.websocket-global.tutorial -->
## uni.onSocketOpen(options) @onsocketopen
<!-- UTSAPIJSON.websocket-global.description -->
<!-- UTSAPIJSON.websocket-global.param -->
<!-- UTSAPIJSON.websocket-global.returnValue -->
<!-- UTSAPIJSON.websocket-global.compatibility -->
<!-- UTSAPIJSON.websocket-global.tutorial -->
## uni.onSocketError(callback) @onsocketerror
<!-- UTSAPIJSON.websocket-global.description -->
<!-- UTSAPIJSON.websocket-global.param -->
<!-- UTSAPIJSON.websocket-global.returnValue -->
<!-- UTSAPIJSON.websocket-global.compatibility -->
<!-- UTSAPIJSON.websocket-global.tutorial -->
## uni.sendSocketMessage(options) @sendsocketmessage
<!-- UTSAPIJSON.websocket-global.description -->
<!-- UTSAPIJSON.websocket-global.param -->
<!-- UTSAPIJSON.websocket-global.returnValue -->
<!-- UTSAPIJSON.websocket-global.compatibility -->
<!-- UTSAPIJSON.websocket-global.tutorial -->
## uni.onSocketMessage(callback) @onsocketmessage
<!-- UTSAPIJSON.websocket-global.description -->
<!-- UTSAPIJSON.websocket-global.param -->
<!-- UTSAPIJSON.websocket-global.returnValue -->
<!-- UTSAPIJSON.websocket-global.compatibility -->
<!-- UTSAPIJSON.websocket-global.tutorial -->
## uni.closeSocket(options) @closesocket
<!-- UTSAPIJSON.websocket-global.description -->
<!-- UTSAPIJSON.websocket-global.param -->
<!-- UTSAPIJSON.websocket-global.returnValue -->
<!-- UTSAPIJSON.websocket-global.compatibility -->
<!-- UTSAPIJSON.websocket-global.tutorial -->
## uni.onSocketClose(callback) @onsocketclose
<!-- UTSAPIJSON.websocket-global.description -->
<!-- UTSAPIJSON.websocket-global.param -->
<!-- UTSAPIJSON.websocket-global.returnValue -->
<!-- UTSAPIJSON.websocket-global.compatibility -->
<!-- UTSAPIJSON.websocket-global.tutorial -->
<!-- UTSAPIJSON.general_type.name -->
<!-- UTSAPIJSON.general_type.param -->
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册