current 方法是 Path 对象中的一个方法,用于返回当前选定的节点,即 Path 对象表示的路径的末尾节点。如果 Path 对象是空的,将返回 null。
current 方法不接受任何参数。
该方法返回一个节点对象,表示 Path 对象表示的路径的末尾节点。
如果 Path 对象是空的,将返回 null。
const path = Yuka.Path.fromString('root/level1/level2');
const current = path.current(); // 返回 'level2' 节点,即路径的末尾节点
current 方法是一个纯函数,不会改变 Path 对象本身。Path 对象表示的路径不存在,current 方法将返回 null。current 方法的执行效率较高,可以用于需要频繁访问 Path 对象末尾节点的场景。