跳至主要内容

set-filter

描述

当按指定条件过滤数据时触发

用法

"set-filter": ({
match?: string | null,
by?: string,
highlight?: boolean,
strict?: boolean
}) => void;

参数

set-filter 事件的回调函数可接受一个包含以下参数的对象:

  • match - (可选)匹配模式
  • by - (可选)用于搜索的 task 对象属性
  • highlight - (可选)定义是否高亮显示匹配结果
  • strict - (可选)若启用严格过滤模式则为 true;否则为 false
信息

如需处理内部事件,可使用 Event Bus 方法

示例

const { ToDo, Toolbar } = todo;
const { tasks, users, projects } = getData();

const list = new ToDo("#root", {
tasks,
users,
projects,
});

const toolbar = new Toolbar("#toolbar", {
api: list.api,
});

// 订阅 "set-filter" 事件
list.api.on("set-filter", (obj) => {
console.log(obj);
});

相关文章: 任务排序与过滤