【问题标题】:Laravel mix doesn't see img elements in vue componentsLaravel mix 在 vue 组件中看不到 img 元素
【发布时间】:2017-11-07 11:20:32
【问题描述】:

Laravel Mix 将 scss 中使用的图像从资源文件夹移动到公用文件夹,但不会将图像从我在 vuejs 组件中使用的 img 标签的 src 属性移动...

<img src="images/logo.png" >

我必须做什么?

【问题讨论】:

  • 您的网络标签中的请求是什么?

标签: laravel webpack vue.js vuejs2 laravel-mix


【解决方案1】:

将您的代码更改为 &lt;img src="./images/logo.png" &gt;

编辑

考虑到从resouces/assets/js/components/Example.vueresources/assets/img/logo.jpg 的相对路径,图像标签应该是 。

【讨论】:

  • 我建议将徽标放在/public/img 并使用绝对路径&lt;img src="/img/logo.png" &gt;
  • ERROR Failed to compile with 1 errors This relative module was not found: * ./images/logo.png in ./~/vue-loader/lib/template-compiler?{"id":"data-v-42bd4064"}!./~/vue-loader/lib/selector.js?type=template&amp;index=0!./resources/assets/js/views/Home.vue
  • @fiter,您必须将组件文件的相对路径写入图像。假设组件在resources/assets/js/components 中,图像在resources/assets/images 中。你会写&lt;img src="../../images/logo.jpg"&gt;
  • @fiter,很高兴我能帮上忙。我更新了我的答案以反映完整的解决方案,请接受它以将问题标记为已解决。
猜你喜欢
  • 2019-08-03
  • 2020-03-09
  • 2021-04-23
  • 2019-02-13
  • 2014-12-17
  • 1970-01-01
  • 2018-04-28
  • 2019-11-10
  • 1970-01-01
相关资源
最近更新 更多