ReadTip 阅读提示
阅读提示组件。
何时使用
当 html 文档中需要对特定内容进行提示时使用。
基本用法
通过设置 selector 选择需要显示 readtip 的元素,传入 title 和 content 设置显示的内容。
Let's see how to use ReadTip
Set selector to display readtip
The following is the target you want to show readtip
@Jack包括多个提示的 readtip
传入多个 rule,设置不同元素的 readtip 显示模式。
Multiple Readtips
You can pass in multiple rules to display different readtips
Click here to display first content
Click here to display second content
Hover here to display third content
Hover here to display third content
传入模板显示内容
可以通过传入 template 自定义需要显示的内容,传入 template 时不必再传入 title 和 content。
You can also pass in template
Write your own template
The following is the target you want to show readtip
DEVUI Course
Another DEVUI Course with same class name
异步获取数据
You can pass data asynchronously
Using function fullElement to pass data
The following is the target you want to show readtip
Display readtip
ReadTip 参数
参数名 | 类型 | 默认 | 说明 | 跳转 Demo |
---|---|---|---|---|
read-tip-options | ReadTipOptions | -- | 必选,配置提示选项 | 基本用法 |
read-tip-options.rules | ReadTipRules | -- | 必选,配置 readtip 内容 | 包括多个提示的 readtip |
ReadTip 插槽
插槽名 | 说明 |
---|---|
content | 自定义内容 |
ReadTip 类型定义
ReadTipOptions
interface ReadTipOptions {
trigger?: 'hover' | 'click'; // 默认值是 hover
showAnimate?: boolean; // 默认值是 false
mouseenterTime?: number; // 默认值是 100
mouseleaveTime?: number; // 默认值是 100
position?: PositionType | PositionType[]; // 默认值是 'top'
overlayClassName?: string; // 默认值为空字符串
appendToBody?: boolean; // 默认值为true
rules: ReadTipRules;
}
ReadTipRules
type ReadTipRules = ReadTipRule | ReadTipRule[];
ReadTipRule
interface ReadTipRule {
key?: string;
selector: string;
trigger?: 'hover' | 'click'; // 可以继承自 ReadTipOptions
title?: string;
content?: string;
showAnimate?: boolean; // 可以继承自 ReadTipOptions
mouseenterTime?: number; // 可以继承自 ReadTipOptions
mouseleaveTime?: number; // 可以继承自 ReadTipOptions
position?: PositionType | PositionType[]; // 可以继承自 ReadTipOptions
overlayClassName?: string; // 可以继承自 ReadTipOptions
appendToBody?: boolean; //可以继承自 ReadTipOtions
//customData与template搭配使用,customData为传入模板的上下文,可以自定义模板内容
dataFn?: ({
element,
rule: ReadTipRule,
}) => Observable<{ title?: string; content?: string; template?: TemplateRef<any>; customData?: any }>;
}