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

The principle and basic use of Vue.use() in Vue

Table of contents Preface 1. Understanding with e...

The correct way to use Homebrew in Linux

Many people use Linux Homebrew. Here are three ti...

Detailed explanation of Linux dynamic library generation and usage guide

The file name of the dynamic library file under L...

The DOCTYPE mode selection mechanism of well-known browsers

Document Scope This article covers mode switching...

Docker container time zone error issue

Table of contents background question Problem ana...

MySQL 8.0.16 Win10 zip version installation and configuration graphic tutorial

This article shares with you the installation and...

Vue implements custom "modal pop-up window" component example code

Table of contents Preface Rendering Example Code ...

The pitfall record of case when judging NULL value in MySQL

Table of contents Preface Mysql case when syntax:...

Detailed explanation of MySQL table name case-insensitive configuration method

By default, MySQL in Linux distinguishes between ...

Introduction to the use and difference between in and exists in MySQL

First put a piece of code for(int i=0;i<1000;i...

Detailed installation history of Ubuntu 20.04 LTS

This article records the creation of a USB boot d...

Design Association: Why did you look in the wrong place?

I took the bus to work a few days ago. Based on m...