In a Vue project, image files can be placed in the static resource directory (static or public), assets subdirectory or component file. You can reference images using the src attribute and use different paths depending on where the image is placed.
Vue image file placement location
In a Vue project, image files are usually placed in the following locations:
1. Static resource directory in the project root directory
static
or public
2. assets
Subdirectory
src/assets
3. Within component files
For images that need to be embedded into components, you can place them in the component file: src/components/MyComponent.vue
<code class="html"><template> <img src="./image.jpg" alt="My Image"> </template></code>
How to cite pictures?
Use src
Attribute:
<code class="html"><img src="/static/image.jpg" alt="My Image"></code>
Relative to component file path:
<code class="html"><img src="./image.jpg" alt="My Image"></code>
For images embedded in component files, use relative paths:
<code class="html"><img src="@/assets/image.jpg" alt="My Image"></code>
The above is the detailed content of Where to put vue image files. For more information, please follow other related articles on the PHP Chinese website!