From b4dfb77867bcd9050c31dd5eb854e52c567bfb39 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Sat, 3 Feb 2024 21:48:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96=E5=BD=93?= =?UTF-8?q?=E5=89=8DESM=E6=96=87=E4=BB=B6=E5=9C=B0=E5=9D=80=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/library/init/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/noname/library/init/index.js b/noname/library/init/index.js index 41f3f2612..2f2cb4baa 100644 --- a/noname/library/init/index.js +++ b/noname/library/init/index.js @@ -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); + } }