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

Detailed explanation of three commonly used web effects in JavaScript

Table of contents 1 element offset series 1.1 Off...

Detailed explanation of html download function

The new project has basically come to an end. It ...

mysql5.7.18.zip Installation-free version configuration tutorial (windows)

This is the installation tutorial of mysql5.7.18....

jQuery canvas generates a poster with a QR code

This article shares the specific code for using j...

MySQL 8.0.3 RC is about to be released. Let’s take a look at the changes

MySQL 8.0.3 is about to be released. Let’s take a...

Use of Linux relative and absolute paths

01. Overview Absolute paths and relative paths ar...

Realize super cool water light effect based on canvas

This article example shares with you the specific...

HTML table tag tutorial (35): cross-column attribute COLSPAN

In a complex table structure, some cells span mul...

Build a server virtual machine in VMware Workstation Pro (graphic tutorial)

The VMware Workstation Pro version I use is: 1. F...

Nginx reverse proxy to go-fastdfs case explanation

background go-fastdfs is a distributed file syste...

Key knowledge summary of Vue development guide

Table of contents Overview 0. JavaScript and Web ...