Solution to the problem that the Vue page image does not display

Solution to the problem that the Vue page image does not display

When making a new version of the configuration interface, I used the vue framework to implement it. When configuring the page image, I found that there was a picture whose path was correct but the picture was not displayed.

Phenomenon:

The network page resources do not report an error, and the status code is still 200. There is nothing in the preview. After entering, I found that 200 appears for any word I enter.

Solution:

Configure the path of static resources in webpack

1. Find vue.config.js

2. Add a key in devServer under module.exports

contentBase:path.join(_dirname,'src')

This means that webpack-dev-server will use the current path as the requested resource path

About contentBase, reference article

https://www.jb51.net/article/222324.htm

Static resources:

Method 1: Directly enter the path

<img class="sys_logo" src="./assets/images/top-logo.png"/>

Method 2: Using require

import logoUrl from './top-logo.png'
const Images = {
    logoUrl
}
export default Images

Method 3: Modularization

import logoUrl from './top-logo.png'
const Images = {
    logoUrl
}
export default Images

use:

js:

import Images from './assets/images'
html:
<img class="sys_logo" :src="Images.logoUrl" />

This is the end of this article about the solution to the problem of images not displaying on vue pages. For more information about the problem of images not displaying on vue pages, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • The problem and solution of Vue dynamically loading pictures not being displayed when cross-domain
  • Solve the problem of Vue dynamically loading local images
  • Solution for dynamically loading image src based on vue
  • Problem and solution of image loading failure in Vue

<<:  Detailed explanation of nginx configuration file interpretation

>>:  MySQL database operations (create, select, delete)

Recommend

Docker+nextcloud to build a personal cloud storage system

1. Docker installation and startup yum install ep...

MySQL multi-master and one-slave data backup method tutorial

Overview Operations on any one database are autom...

MySql COALESCE function usage code example

COALESCE is a function that refers to each parame...

Several solutions for CSS record text icon alignment

It is very common to see images and text displaye...

How to install and persist the postgresql database in docker

Skip the Docker installation steps 1. Pull the po...

Detailed introduction to Mysql date query

Query the current date SELECT CURRENT_DATE(); SEL...

React Diff Principle In-depth Analysis

Table of contents Diffing Algorithm Layer-by-laye...

Mysql | Detailed explanation of fuzzy query using wildcards (like,%,_)

Wildcard categories: %Percent wildcard: indicates...

How to deploy MySQL 5.7 & 8.0 master-slave cluster using Docker

> Deploy MySQL 5.7 cluster master & slave ...

Use js in html to get the local system time

Copy code The code is as follows: <div id=&quo...

JavaScript implements simple calculator function

This article shares the specific code of JavaScri...

How to use the debouce anti-shake function in Vue

Table of contents 1. Anti-shake function 2. Use d...

Vue parent component calls child component function implementation

Vue parent component calls the function of the ch...