LoginSignup
0
0

More than 3 years have passed since last update.

Vue-CLI 3 背景画像の「@」が変換されない

Posted at

@はsrc/のエイリアスです。

vue.config.jsでデフォルトそういう設定になっているので使いまくってると、たまに変換されない時があって困る。

select {
        background-image: url('@/assets/img/image.svg');
        }

↓できた

select {
        background-image: url('~@/assets/img/image.svg');
        }

In order to resolve an alias (@), as you are using, it is mandatory webpack handles the request as a module request. Using the prefix ~ enforces webpack treat the request as a module request, similar to require('some-module/image.svg').

(あなたのような使い方のエイリアス(@)を解決するためには、webpackがリクエストをモジュールリクエストとして扱う必要があります。
接頭辞〜を使用するとwebpackはrequire( 'some-module / image.svg')のようにリクエストをモジュールリクエストとして扱います。)

参考リンク:
https://stackoverflow.com/questions/51812496/vue-cli-3-use-background-image-in-style-tag

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0