Tips

Tool tips Including two types tips-dialog and tips-plain.

tips-dialog

Attribute  NameDescriptionTypeDefaultMandatory
classNameCustom   classStringfalse
showShow   control component or notBooleantruefalse
typedialog indicates the style of dialog box, rectangle for rectangle style.Stringdialogfalse
onCloseTapWhen   the type value is rectangle, component clicking close the icon callback.()   => voidfalse
iconUrlShow   the icon urlStringfalse

Slots

slotNameDescription
contentUsed   to render tip text contents
operationUsed   to render right-hand operation area

tips-plain

Attribute  NameDescriptionTypeDefaultMandatory
classNameCustom   classStringfalse
timeAutomatic   close time (in milliseconds)Number5000(ms)false
onClosecallback   and close tip box()   => voidfalse

Example

copy
{
  "defaultTitle": "AntUI Component Library",
  "usingComponents": {
    "tips-dialog": "mini-antui/es/tips/tips-dialog/index",
    "tips-plain": "mini-antui/es/tips/tips-plain/index"
  }
}

tips-dialog

copy
<view>
  <tips-dialog
    show="{{showDialog}}"
    className="dialog"
    type="dialog"
  >
    <view class="content" slot="content">
      <view>hello,</view>
      <view>Welcome to use the Mini Program extension component library</view>
    </view>
    <view slot="operation" class="opt-button" onTap="onDialogTap">OK</view> 
  </tips-dialog>
  <tips-dialog
    iconUrl="https://gw.alipayobjects.com/zos/rmsportal/AzRAgQXlnNbEwQRvEwiu.png"
    type="rectangle"
    className="rectangle"
    onCloseTap="onCloseTap"
    show="{{showRectangle}}">
    <view class="content" slot="content">
      Add to home page
    </view>
    <view slot="operation" class="add-home" onTap="onRectangleTap">Add it now</view>
  </tips-dialog>
</view>
copy
Page({
  data: {
    showRectangle: true,
    showDialog: true,
  },
  onCloseTap() {
    this.setData({
      showRectangle: false,
    });
  },
  onRectangleTap() {
    my.alert({
      content: 'do something',
    });
  },
  onDialogTap() {
    this.setData({
      showDialog: false,
    });
  },
});
copy
.rectangle {
  position: fixed;
  bottom: 100px;
}

.dialog {
  position: fixed;
  bottom: 10px;
}

.content {
  font-size: 14px;
  color: #fff;
}

.opt-button {
  width: 51px;
  height: 27px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 12px;
  border: #68BAF7 solid 1rpx;
}

.add-home {
  width: 72px;
  height: 27px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #56ADEB;
  color: #fff;
  font-size: 14px;
}

tips-plain

copy
<tips-plain onClose="onClose" time="{{time}}">{{content}}</tips-plain>
copy
Page({
  data: {
    content: 'OK',
    time: 2000,
  },
  onClose() {
    my.alert({
      title: '12321'
    });
  }
});