当前位置:网站首页>Vite dynamically loads static resource pictures, and fixes the 404 problem of pictures after packaging.
Vite dynamically loads static resource pictures, and fixes the 404 problem of pictures after packaging.
2022-07-25 02:24:00 【TangAcrab】
1、 solve . Use new URL
/*** * @description vite Dynamically load static resource pictures * @params string name - Image name */
export const dynamicGetImg = (name: string) => {
try {
return new URL(`../assets/menu-icon/${
name}`, import.meta.url).href
} catch (error) {
console.log(error)
}
}
Just pass in the name of the picture in the directory
Reference article Acknowledgement
边栏推荐
- Is it necessary to increase the number of milliseconds and save several KB of memory in the program?
- About the relationship between parent process and child process (UAC bypass idea)
- Introduction to web security telent testing and defense
- Speed comparison between 64 bit width and 32 bit width of arm64 memory
- Case analysis of building exhibition service management system with low code development platform
- How MySQL 8.0 based on TRX_ Id find the statement of the whole transaction
- Ecosystem long-term observation data product system
- Why can't reading more books improve your writing?
- Automatically create partition tables by time and month in PostgreSQL
- Agreement on sharing agricultural scientific data in China
猜你喜欢

High performance memory recovery technology for decrypting ark -- HPP GC

Peripherals: timer, watchdog and RTC

Peripherals: interrupt system of keys and CPU

Simulate the implementation of strstr

My creation anniversary (3rd Anniversary)

R language uses logistic regression, ANOVA, outlier analysis and visual classification iris iris data set

Easy to master SSO single sign on, see this article

Use Fiddler to capture apps

Pycharm writes SQLite statements without code prompts

Use SAP ui5 application to consume create and delete operations of OData in business application studio
随机推荐
Using multithreaded execution method in Lua script based on nlua implementation
Dynamic memory development
Detailed explanation of the principles and differences between static pages and dynamic pages
Fraud detection using CSP
Common functional interfaces_ Predicate interface_ Default method and and predicate interface exercise_ Set interface filtering
Anacona has too many environments?? How to view your current environment in jupyter
Mobile Robotics (3) Kalman filter
Introduction to ORM framework - what is ORM framework?
Talk about resume optimization and interview skills of algorithm post!
Hongmeng harmonyos 3 official announcement: officially released on July 27; Apple slowed down the recruitment and expenditure of some teams in 2023; Russia fined Google 2.6 billion yuan | geek headlin
6-11 vulnerability exploitation - use the built environment to send emails
How to use ES6 async and await (basic)
JS utils tool function that makes you get twice the result with half the effort
[recognize cloud Nativity] Chapter 4 cloud network section 4.9.4.3 - smart network card usage scenario - network acceleration implementation
Detailed explanation of MySQL, Oracle and PostgreSQL database index failure scenarios
[leetcode] 2. Add two numbers - go language problem solving
Standard transfer function
Upgrade the leapfrog products again, and the 2023 Geely Xingrui will be sold from 113700 yuan
Summary and sorting of XSS (cross site script attack) related content
Example demonstration of "uncover the secrets of asp.net core 6 framework" [02]: application development based on routing, MVC and grpc