api.intercept()
描述
用于拦截并阻止内部事件
用法
api.intercept(
event: string,
callback: function,
config?: { tag?: number | string | symbol }
): void;
参数
event- (必填)要触发的事件callback- (必填)要执行的回调函数(回调参数取决于所触发的事件)config- (可选)存储以下参数的对象:tag- (可选)操作标签。您可以使用标签名称通过detach方法移除操作处理器
事件
示例
以下示例展示了如何在初始化时关闭所有可折叠行。
// 创建 Pivot
const table = new pivot.Pivot("#root", {
fields,
data: dataset,
config: {
rows: ["studio", "genre"],
columns: [],
values: [
{
field: "title",
method: "count"
},
{
field: "score",
method: "max"
}
]
}
});
// 在初始化时关闭所有行
table.api.intercept("render-table", (ev) => {
ev.config.data.forEach((row) => (row.open = false));
}, {tag: "render-table-tag"});
相关文章:render-table