undefinedfix
Sign in

How about webpack?

SBRIGHT1 edited in Mon, 16 May 2022

This is my file directory

.logo { background: url('/static/img/hospital_ logo.png ) no repeat left top; background size: 100% 100%; width: 45px; height: 45px; display: inline block; margin: 8px 0 010px; float: left;} This is my CSS background image path

But I now packaged these pictures still can not be displayed, but I can run local..

Ask the great God to tell me how to use it

2 Replies
gjotc
commented on Mon, 16 May 2022

background- image:url ('...') try it on the label

ChillieCode
commented on Mon, 16 May 2022
  • Make sure that the static directory has been packaged into the. / dist directory, otherwise check the configuration of webpack;
  • The packaged code needs to be viewed on a web server, and it is invalid to open it directly;
  • /The former is suitable for domain name access, while the latter is suitable for various formats.

Suppose the domain name is: http://127.0.0.1/ So http://127.0.0.1/static/ ***It can be displayed normally. But if your domain name is http://127.0.0.1/app/ So http://127.0.0.1/app/static/ ***Access error.

Here are three solutions:

  • There is no such problem when you put it directly on the online server, because online servers are generally top-level (for example: domain.com )Or secondary domain name (e.g admin.domain.com );
  • For local preview, such as Apache, you can try virtualhost virtual host configuration;
  • When previewing locally, modify. / dist/ index.html , add < base=“ http://127.0.0.1/app/ "/ > statement, refer to HTML < base > tag;
lock This question has been locked and the reply function has been disabled.