持续创作,加速成长!这是我参与「掘金日新计划 · 10 月更文挑战」的第23天,点击查看活动详情
Popup控制
给组件绑定popup弹窗,并设置弹窗内容,交互逻辑和显示状态。
接口:
bindPopup(show: boolean, popup: PopupOptions | CustomPopupOptions): T;
指给组件绑定Popup弹窗,设置参数show为true弹出弹框。 show: 弹窗显示状态,默认值为false,隐藏弹窗。 popup: 配置当前弹窗提示的参数。
PopupOptions类型说明
declare interface PopupOptions {
/**
* Information in the pop-up window.
* @since 7
*/
message: string;
/**
* placement On Top
* @since 7
*/
placementOnTop?: boolean;
/**
* The first button.
* @since 7
*/
primaryButton?: {
/**
* Button text value
* @since 7
*/
value: string;
/**
* action
* @since 7
*/
action: () => void;
};
/**
* The second button.
* @since 7
*/
secondaryButton?: {
/**
* Button text value
* @since 7
*/
value: string;
/**
* action
* @since 7
*/
action: () => void;
};
/**
* on State Change
* @since 7
*/
onStateChange?: (event: { isVisible: boolean }) => void;
/**
* The offset of the sharp corner of popup.
* @since 9
*/
arrowOffset?: Length;
}
- message:弹窗信息内容。
- placementOnTop:是否在组件上方显示,默认值为false
- arrowOffset:popup箭头在弹窗处的偏移。箭头在气泡上下方时,数值为0表示箭头居最左侧,偏移量为箭头至最左侧的距离,默认居中。箭头在气泡左右侧时,偏移量为箭头至最上侧的距离,默认居中。
- primaryButton:是否在子窗口显示气泡,默认值为false。
- primaryButton:第一个按钮。 value: 弹窗里主按钮的文本。 action: 点击主按钮的回调函数。
- secondaryButton:第二个按钮。 value: 弹窗里辅助按钮的文本。 action: 点击辅助按钮的回调函数。
- onStateChange:弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。
CustomPopupOptions
declare interface CustomPopupOptions {
/**
* builder of popup
* @since 8
*/
builder: CustomBuilder;
/**
* placement of popup
* @since 8
*/
placement?: Placement;
/**
* mask color of popup
* @since 8
*/
maskColor?: Color | string | Resource | number;
/**
* background color of popup
* @since 8
*/
popupColor?: Color | string | Resource | number;
/**
* whether show arrow
* @since 8
*/
enableArrow?: boolean;
/**
* whether hide popup when click mask
* @since 8
*/
autoCancel?: boolean;
/**
* on State Change
* @since 8
*/
onStateChange?: (event: { isVisible: boolean }) => void;
/**
* The offset of the sharp corner of popup.
* @since 9
*/
arrowOffset?: Length;
}
- builder:提示气泡内容的构造器。
- placement:气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。默认值:Placement.Bottom
- arrowOffse:popup箭头在弹窗处的偏移。箭头在气泡上下方时,数值为0表示箭头居最左侧,偏移量为箭头至最左侧的距离,默认居中。箭头在气泡左右侧时,偏移量为箭头至最上侧的距离,默认居中。
- maskColor:提示气泡遮障层的颜色。
- popupColor:提示气泡的颜色。
- enableArrow:是否显示箭头。从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。 默认值:true
- autoCancel:
- 页面有操作时,是否自动关闭气泡。默认值:true
- onStateChange:弹窗状态变化事件回调,参数为弹窗当前的显示状态。