existsProject()
描述
检查指定项目是否存在于 DataStore 中
用法
existsProject({ id: string | number }): boolean;
参数
id- (必填)项目的 ID
返回值
若项目存在,该方法返回 true;否则返回 false
示例
const { ToDo, Toolbar } = todo;
const list = new ToDo("#root", {
projects: [
{ id: "first", label: "First project" },
{ id: "second", label: "Second project" },
{ id: "third", label: "Third project" },
]
});
const toolbar = new Toolbar("#toolbar", {
api: list.api,
});
// 检查项目是否存在
list.existsProject({ id: 1 }); // -> false
list.existsProject({ id: "first" }); // -> true
相关文章: 项目对象