urlToPath
约 90 字小于 1 分钟
2025-10-13
Karin API Docs / urlToPath
函数: urlToPath()
urlToPath(
url
):string
定义于: packages/core/src/utils/fs/path.ts:94
根据传入的 import.meta.url 计算相对于项目根目录的路径,返回需要的 '../' 层级。
参数
url
string
import.meta.url
返回
string
相对路径的层级数量,用 '../' 表示
示例
// 在 plugins/karin-plugin-example/index.ts 中使用
urlToPath(import.meta.url)
// -> '../../'