Tips 引导

小提示。分tips-dialogtips-plain两种类型。

扫码体验:
Tips 引导 - 图1

tips-dialog

属性说明类型默认值必选
className自定义classStringfalse
show控制组件是否展示Booleantruefalse
typedialog表示对话框的样式类型,rectangle表示矩形的样式类型。Stringdialogfalse
onCloseTaptype值为rectangle时,组件点击关闭icon的回调() => voidfalse
iconUrl展示icon的url地址Stringfalse

slots

slotName说明
content用于渲染提示的正文内容
operation用于渲染右侧操作区域

tips-plain

属性说明类型默认值必选
className自定义classStringfalse
time自动关闭时间(单位毫秒)Number5000(ms)false
onClose回调并关闭提示框() => voidfalse

示例

  1. {
  2. "defaultTitle": "小程序AntUI组件库",
  3. "usingComponents": {
  4. "tips-dialog": "mini-antui/es/tips/tips-dialog/index",
  5. "tips-plain": "mini-antui/es/tips/tips-plain/index"
  6. }
  7. }

tips-dialog

  1. <view>
  2. <tips-dialog
  3. show="{{showDialog}}"
  4. className="dialog"
  5. type="dialog"
  6. >
  7. <view class="content" slot="content">
  8. <view>hello,</view>
  9. <view>欢迎使用小程序扩展组件库mini-antui</view>
  10. </view>
  11. <view slot="operation" class="opt-button" onTap="onDialogTap">知道了</view>
  12. </tips-dialog>
  13. <tips-dialog
  14. iconUrl="https://gw.alipayobjects.com/zos/rmsportal/AzRAgQXlnNbEwQRvEwiu.png"
  15. type="rectangle"
  16. className="rectangle"
  17. onCloseTap="onCloseTap"
  18. show="{{showRectangle}}">
  19. <view class="content" slot="content">
  20. 把“城市服务”添加到首页
  21. </view>
  22. <view slot="operation" class="add-home" onTap="onRectangleTap">立即添加</view>
  23. </tips-dialog>
  24. </view>
  1. Page({
  2. data: {
  3. showRectangle: true,
  4. showDialog: true,
  5. },
  6. onCloseTap() {
  7. this.setData({
  8. showRectangle: false,
  9. });
  10. },
  11. onRectangleTap() {
  12. my.alert({
  13. content: 'do something',
  14. });
  15. },
  16. onDialogTap() {
  17. this.setData({
  18. showDialog: false,
  19. });
  20. },
  21. });
  1. .rectangle {
  2. position: fixed;
  3. bottom: 100px;
  4. }
  5. .dialog {
  6. position: fixed;
  7. bottom: 10px;
  8. }
  9. .content {
  10. font-size: 14px;
  11. color: #fff;
  12. }
  13. .opt-button {
  14. width: 51px;
  15. height: 27px;
  16. display: flex;
  17. justify-content: center;
  18. align-items: center;
  19. color: #fff;
  20. font-size: 12px;
  21. border: #68BAF7 solid 1rpx;
  22. }
  23. .add-home {
  24. width: 72px;
  25. height: 27px;
  26. display: flex;
  27. justify-content: center;
  28. align-items: center;
  29. background-color: #56ADEB;
  30. color: #fff;
  31. font-size: 14px;
  32. }

tips-plain

  1. <tips-plain onClose="onClose" time="{{time}}">{{content}}</tips-plain>
  1. Page({
  2. data: {
  3. content: '我知道了',
  4. time: 2000,
  5. },
  6. onClose() {
  7. my.alert({
  8. title: '12321'
  9. });
  10. }
  11. });

原文: https://docs.alipay.com/mini/component-ext/tips