tickle.behavior.ts 942 B

12345678910111213141516171819202122232425
  1. import Message from '../../miniprogram_npm/tdesign-miniprogram/message/index';
  2. export default Behavior({
  3. data: {
  4. $messageId: 't-message',
  5. },
  6. lifetimes: {},
  7. methods: {
  8. showMessage(type: 'info' | 'success' | 'warning' | 'error', content: string, duration = 3000) {
  9. (<any>Message)[type]({
  10. selector: `#${this.data.$messageId}`,
  11. offset: [90, 32],
  12. duration, content,
  13. });
  14. },
  15. showInfoMessage(content: string, duration?: number) { this.showMessage('info', content, duration); },
  16. showSuccessMessage(content: string, duration?: number) { this.showMessage('success', content, duration); },
  17. showWarnMessage(content: string, duration?: number) { this.showMessage('warning', content, duration); },
  18. showErrorMessage(content: string, duration?: number) { this.showMessage('error', content, duration); },
  19. }
  20. });
  21. export function getTickleContext(this: any) {
  22. return this as Tickle;
  23. }