当前位置:网站首页>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
边栏推荐
- Creating elements of DOM series
- H5 common positioning function package
- "No such plugin: cloudbees folder" solution appears when Jenkins selects the recommended plug-in for the first time
- Open sharing of scientific data in the context of open science: the practice of the national Qinghai Tibet Plateau scientific data center
- HAC cluster is modified to stand-alone
- MySQL advanced (13) command line export import database
- Query the thread information of MySQL server (detailed explanation)
- Data management process model of science and technology planning project
- Is it necessary to increase the number of milliseconds and save several KB of memory in the program?
- Arthas case: dynamic update application logger level
猜你喜欢

Simulate the implementation of strstr

Computing network, AI first, shengteng AI helps operators' Digital Transformation -- work together to win-win Computing Era
![[recognize cloud Nativity] Chapter 4 cloud network section 4.9.4.3 - smart network card usage scenario - network acceleration implementation](/img/9a/b69036bf920706360d8b293dad2a89.png)
[recognize cloud Nativity] Chapter 4 cloud network section 4.9.4.3 - smart network card usage scenario - network acceleration implementation

Coal industry supply chain centralized mining system: digitalization to promote the transformation and upgrading of coal industry

Nacos service discovery data model

Easy to master SSO single sign on, see this article

Details of C language compilation preprocessing and comparison of macros and functions

Talk about what's going on with C # backstage GC?

UDP message structure and precautions

Deep understanding of string class
随机推荐
Consul cluster deployment
These 11 chrome artifacts are extremely cool to use
Actf questions (dropper+master_of_dns)
Simulate the implementation of strstr
[linear DP] Digital triangle
Industrial control safety PLC firmware reverse II
What are the important trends revealed by the release of "operator data viability index"?
Detailed explanation of manually writing servlet in idea
Industrial control safety PLC firmware reverse III
Let's customize the loader
Vs2019 configuring Qt5 development environment
Summary and sorting of XSS (cross site script attack) related content
Deamnet|filenotfounderror: [winerror 3] the system cannot find the specified path.: '/ Datasettest\\Set12‘
CSRF attack principle scenario
How to communicate with aliens
Detailed explanation of the principles and differences between static pages and dynamic pages
6-10 vulnerability exploitation SMTP experimental environment construction
iptables :chains, target
Project management tool Zen
Promise basic use