uniapp中uview组件库的AlertTips 警告提示使用方法

目录

#使用场景

#平台差异说明

#基本使用

#图标

#可关闭的警告提示

#API

#Props

#Events


警告提示,展现需要关注的信息。

#使用场景

  • 当某个页面需要向用户显示警告的信息时。
  • 非浮层的静态展现形式,始终展现,不会自动消失,用户可以点击关闭。

#平台差异说明

App H5 微信小程序 支付宝小程序 百度小程序 头条小程序 QQ小程序

#基本使用

  • 通过titledescription设置组件的标题和描述内容,如果内容和标题同时存在,标题字体会被加粗加大

  • 通过type设置主题类型,有primary,success,error,warning,info可选值

    <template> <u-alert-tips type="warning" :title="title" :description="description"></u-alert-tips> </template> <script> export default { data() { title: '登高望远', description: '欲穷千里目,更上一层楼' } } </script>

#图标

通过show-icon设置是否显示图标,作用是让信息类型更加醒目。

注意 :当前版本图标为uView内置图标,根据type参数显示不同的图标,无法自定义。

复制代码
<u-alert-tips type="warning" :show-icon="true"></u-alert-tips>

#可关闭的警告提示

显示关闭按钮,点击可关闭警告提示。

  • close-text参数配置关闭的文字,默认为一个叉的icon图标。close-abletrue时有效
  • close-able参数配置是否允许关闭的文字或图标

注意

由于props传参的限制,您需要监听组件的close事件,并在此此事件中设置show参数为false,才能关闭组件。

复制代码
<template>
	<u-alert-tips :show="show" type="error" @close="show = false" :title="title" :close-able="true"></u-alert-tips>
	
	<u-alert-tips type="error" :title="title" close-text="close" :description="description" :close-able="true"></u-alert-tips>
</template>

<script>
	export default {
		data() {
			title: '寻隐者不遇',
			description: '松下问童子,言师采药去。只在此山中,云深不知处。',
			show: true
		}
	}
</script>

#API

#Props

参数 说明 类型 默认值 可选值
title 显示的文字 String - -
description 辅助性文字,颜色比title浅一点,字号也小一点,可选 String - -
close-able 关闭按钮(默认为叉号icon图标) Boolean false true
type 使用预设的颜色 String warning success / primary / error / info
close-text 用文字替代关闭图标,close-abletrue时有效 String - -
show-icon 是否显示左边的辅助图标 Boolean false true
show 显示或隐藏组件 Boolean true false
icon 1.5.8 左侧的图标名称,如设置typeshow-icon值,会有一个默认的图标 String - -
icon-style 1.5.8 自定义图标的样式,对象形式 Object - -
title-style 1.5.8 自定义标题的样式,对象形式 Object - -
desc-style 1.5.8 自定义内容的样式,对象形式 Object - -

#Events

事件名 说明 回调参数
close 点击关闭按钮时触发,需在此回调设置showfalse -
click 点击组件时触发 -
相关推荐
宠友信息5 小时前
2025社交+IM及时通讯社区APP仿小红书小程序
java·spring boot·小程序·uni-app·web app
“负拾捌”6 小时前
python + uniapp 结合腾讯云实现实时语音识别功能(WebSocket)
python·websocket·微信小程序·uni-app·大模型·腾讯云·语音识别
局外人LZ1 天前
Uniapp脚手架项目搭建,uniapp+vue3+uView pro+vite+pinia+sass
前端·uni-app·sass
2501_915918411 天前
在 iOS 环境下查看 App 详细信息与文件目录
android·ios·小程序·https·uni-app·iphone·webview
前端呆头鹅1 天前
Websocket使用方案详解(uniapp版)
websocket·网络协议·uni-app
浮桥1 天前
uniapp+h5 公众号实现分享海报绘制
uni-app·notepad++
2501_916007471 天前
没有 Mac 用户如何上架 App Store,IPA生成、证书与描述文件管理、跨平台上传
android·macos·ios·小程序·uni-app·iphone·webview
wangjun51591 天前
uniapp uni.downloadFile 偶发性下载文件失败 无响应
uni-app
2501_915106322 天前
当 Perfdog 开始收费之后,我重新整理了一替代方案
android·ios·小程序·https·uni-app·iphone·webview
2501_915918412 天前
中小团队发布,跨平台 iOS 上架,证书、描述文件创建管理,测试分发一体化方案
android·ios·小程序·https·uni-app·iphone·webview