/*** 获取完整解析静态资源的url,如图片、svg等* @param {string} path 静态资源在在assets中的地址,例如:images/pubilc/logo.png* @returns {string}*/
export function getStaticUrl(path: string | undefined): string {if (typeof path == "undefined") {return "";}let paths = path.split("/");// 去掉空值或者.或者..paths = paths.filter((item) => item !== "" && item !== "." && item !== "..");const fullPath = `../assets/${paths.join("/")}`;const res = new URL(fullPath, import.meta.url).href;return res;
}
vite静态资源处理
本文来自博客园,作者:小周同学~,转载请注明原文链接:https://www.cnblogs.com/xiaozhou-wuyu/p/19108255