代码提交--
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 857 B |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 180 B |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 299 B |
After Width: | Height: | Size: 20 KiB |
|
@ -1,5 +0,0 @@
|
||||||
const getImageUrl = (name)=>{
|
|
||||||
return `url(${new URL(name, import.meta.url).href})`
|
|
||||||
}
|
|
||||||
|
|
||||||
export default getImageUrl
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// 将所有图片导入进来
|
||||||
|
|
||||||
|
const req1 = import.meta.glob("../assets/images/**", {eager: true});
|
||||||
|
|
||||||
|
const req = {...req1};
|
||||||
|
|
||||||
|
const imagesMap = {};
|
||||||
|
|
||||||
|
// 循环所有图片,将图片名设置成键,值为导入该图片的地址
|
||||||
|
for (const key in req) {
|
||||||
|
// let name = key.replace(/(\.\/images\/|\..*)/g, '')
|
||||||
|
let name = key.split("/").slice(-1)[0].split(".")[0].replace(/-/g, "");
|
||||||
|
|
||||||
|
// 抛出图片大对象后,文件页面直接引入后将图片的具体名称作为属性就能导入该图片
|
||||||
|
imagesMap[name] = req[key].default;
|
||||||
|
}
|
||||||
|
export default imagesMap
|
||||||
|
|
||||||
|
|
||||||
|
|