Skip to content
广告位招租广告位招租

兼容端

安卓苹果Web鸿蒙小程序

使用示例

vue
<script setup lang="uts">
	import * as TModal from '@/uni_modules/t-modal-api'

	const showMyModal = () => {
	  TModal.showModal({
	    title: '提示',
	    content: 'Turbo UI Modal',
	    confirmText: '确定',
	    cancelText: '取消',
	    showCancel: true,
	    animationDuration: 300,
			success: (result: TModal.TModalResult) => {
				console.log(result)
			},
			fail: (result: TModal.TModalResult) => {
				console.log(result)
			}
	  } as TModal.TModalOptions)
	}
</script>

暴露的类型

ts
export type TModalResult = {
  /**
   * 是否确认
   */
  confirm: boolean
  /**
   * 是否取消
   */
  cancel: boolean
}

export type TModalOptions = {
  /**
   * 标题
   */
  title?: string;
  /**
   * 内容
   */
  content: string;
  /**
   * 确认按钮文本
   */
  confirmText?: string;
  /**
   * 取消按钮文本
   */
  cancelText?: string;
  /**
   * 是否显示取消按钮
   */
  showCancel?: boolean;
  /**
   * 动画持续时间(毫秒)
   */
  animationDuration?: number;
  /**
   * 弹窗 宽度
   */
  width?: number;
  /**
   * 弹窗 高度
   */
  height?: number;
	/**
	 * 按钮圆角
	 */
	btnRadius?: number;
	/**
	 * 弹窗圆角
	 */
	radius?: number;
	/**
	 * 取消按钮背景颜色
	 */
	cancelBgColor?: string;
	/**
	 * 取消按钮文字颜色
	 */
	cancelTextColor?: string;
	/**
	 * 确认按钮背景颜色
	 */
	confirmBgColor?: string;
	/**
	 * 确认按钮文字颜色
	 */
	confirmTextColor?: string;
	/**
	 * 确认按钮宽度(如showCancel = false,那么该值无效)
	 */
	confirmWidth?: number;
	/**
	 * 确认按钮高度
	 */
	confirmHeight?: number;
	/**
	 * 取消按钮宽度
	 */
	cancelWidth?: number;
	/**
	 * 取消按钮高度
	 */
	cancelHeight?: number;
	/**
	 * 背景颜色
	 */
	bgColor?: string;
	/**
	 * 内容高度
	 */
	contentHeight?: number;
	success?: (result:TModalResult) => void;
	fail?: (result:TModalResult) => void;
}