本笔记仅记录了一些本人常用到的,具体请查看https://uniapp.dcloud.io/
8,uni-app中的界面
(1),交互反馈(提示)
1),uni.showToast({
title, <!--提示的内容,长度与 icon 取值有关-->
icon,<!--success(显示成功图标,此时 title 文本最多显示 7 个汉字长度。默认值),loding(显示加载图标,此时 title 文本最多显示 7 个汉字长度),none(不显示图标,此时 title 文本在小程序最多可显示两行,5+App仅支持单行显示。)-->
image,<!--自定义图标的本地路径-->
mask,<!--是否显示透明蒙层,防止触摸穿透,默认:false-->
duration,<!--提示的延迟时间,单位毫秒,默认:1500-->
position,<!--top(居上显示),center(居中显示),bottom(居底显示)-->
success,<!--成功返回的函数-->
fail,<!--失败返回的函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---显示消息提示框---
2):uni.hideToast()
---隐藏消息提示框---
3):uni.showLoading({
title,<!--提示的内容-->
mask,<!--是否显示透明蒙层,防止触摸穿透,默认:false-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---显示 loading 提示框, 需主动调用 uni.hideLoading 才能关闭提示框。---
4):uni.hideLoading()
---隐藏 loading 提示框。---
5):uni.showModal({
title,<!--提示的标题-->
content,<!--提示的内容-->
showCancel,<!--是否显示取消按钮,默认为 true-->
cancelText,<!--取消按钮的文字,默认为"取消",最多 4 个字符-->
cancelColor,<!--取消按钮的文字颜色,默认为"#000000"-->
confirmText,<!--确定按钮的文字,默认为"确定",最多 4 个字符-->
confirmColor,<!--确定按钮的文字颜色,H5平台默认为"#007aff",微信小程序平台默认为"#3CC51F",百度小程序平台默认为"#3c76ff"-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---相当于alert弹出框---
6),uni.showActionSheet(OBJECT)
---显示操作菜单https://uniapp.dcloud.io/api/ui/prompt?id=showmodal---
(2),导航栏的设置
1),uni.setNavigationBarTitle({
title,<!--导航栏标题-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---动态设置当前页面的标题。---
2),uni.setNavigationBarColor({
frontColor,<!--前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000-->
backgroundColor,<!--背景颜色值,有效值为十六进制颜色-->
animation,<!--动画效果-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---设置页面导航条颜色---
3),uni.showNavigationBarLoading({
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---在当前页面显示导航条加载动画。(不支持APP)---
4),uni.hideNavigationBarLoading({
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---在当前页面隐藏导航条加载动画。(不支持APP)---
(3):TabBar的设置
1),uni.setTabBarItem({
index,<!--tabBar 的哪一项,从左边算起-->
text,<!--tab 上的按钮文字-->
iconPath,<!--图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片-->
selectedIconPath,<!--选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---动态设置 tabBar 某一项的内容---
2),uni.setTabBarStyle({
color,<!--tab 上的文字默认颜色,HexColor-->
selectedColor,<!--tab 上的文字选中时的颜色,HexColor-->
backgroundColor,<!--tab 的背景色,HexColor-->
borderStyle,<!--tabBar上边框的颜色, 仅支持 black/white-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---动态设置 tabBar 的整体样式---
3),uni.hideTabBar({
animation,<!--是否需要动画效果,仅微信小程序和百度小程序支持-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---隐藏 tabBar---
4),uni.showTabBar({
animation,<!--是否需要动画效果,仅微信小程序和百度小程序支持-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---显示 tabBar---
5),uni.setTabBarBadge({
index,<!--tabBar的哪一项,从左边算起-->
text,<!--显示的文本,不超过 3 个半角字符-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---为 tabBar 某一项的右上角添加文本---
6),uni.removeTabBarBadge({
index,<!--tabBar的哪一项,从左边算起-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---移除 tabBar 某一项右上角的文本---
7),uni.showTabBarRedDot({
index,<!--tabBar的哪一项,从左边算起-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---显示 tabBar 某一项的右上角的红点。---
8),uni.hideTabBarRedDot({
index,<!--tabBar的哪一项,从左边算起-->
success,<!--接口调用成功的回调函数-->
fail,<!--接口调用失败的回调函数-->
complete,<!--接口调用结束的回调函数(调用成功、失败都会执行)-->
})
---隐藏 tabBar 某一项的右上角的红点。---