vue 动态加载图片,但一直报错

vue中加载图片 banner-biometric2 ,但是一直报这个错:

This dependency was not found:

* /static/banner-biometric2 in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/pages/Home.vue

To install it, you can run: npm install --save /static/banner-biometric2

使用了两种办法解决,都报同样的错误:

  1. import bannerBiometric from '@/assets/images/banner-biometric2'
  2. import bannerBiometric from '/static/banner-biometric2'

一开始图片路径是在 assets 目录下,根据网上查找的资料说是静态资源要放在 static 这个目录下,依然使用 import 引入,但是依然报同样的错误,不明白是什么原因导致的。

阅读 2.3k
1 个回答

你的图片后缀名呢

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题