vue-cli 中 img 的 src 无法引入问题

版权声明:未经同意,不得随意转载转载 https://blog.csdn.net/lucky541788/article/details/85049146

在这里插入图片描述
An error is reported as shown in the figure.

After consulting official documents, it turned out that there was no webpack problem, but another way was found.
在这里插入图片描述
First and foremost,putting your image‘s files in the public directory
在这里插入图片描述
In addition, you will need to first pass the base URL to your component in templates:

data () {
  return {
    baseUrl: process.env.BASE_URL
  }
}

Then:

<img :src="`${baseUrl}my-image.png`">

猜你喜欢

转载自blog.csdn.net/lucky541788/article/details/85049146
今日推荐