添加获取当前ESM文件地址的方法

This commit is contained in:
kuangthree 2024-02-03 21:48:59 +08:00
parent afcefeb995
commit b4dfb77867
1 changed files with 10 additions and 0 deletions

View File

@ -781,4 +781,14 @@ export class LibInit extends Uninstantable {
}
return str;
}
/**
* 在返回当前加载的esm模块相对位置
* @param {*} url 传入import.meta.url
*/
static getCurrentFileLocation(url){
let head = window.location.href.slice(0,window.location.href.lastIndexOf('/')+1);
let ret = url.replace(head,'');
return decodeURIComponent(ret);
}
}