Img 源将 prop 传递给子组件 Vue Js

Img source passed on prop to child component Vue Js

所以,我正在玩 Vue Js,目前在子组件上显示图像时遇到了一些问题,所以,我看起来像这样:

父组件:

<list>
  <post name="post 1" image="somePath"/>
  <post name="post 2" image="somePath"/>
</list>

在我们得到的子组件上

<post>
 <p> {{name}} </p>
 <img src={{somePath}} />
</post>

我尝试了几种使用 require 和其他方法的方法... None 到目前为止,他们已经工作了...... 有什么建议么? 此外,这是我的 img 路径的样子

"@/assets/web/mock/Phonebeats.png"

想办法吧! :)

基本上,在初始渲染时,在 vuejs 有机会渲染您的代码之前,浏览器会看到:

<img src="{{ url }}" />

然后浏览器尝试加载 {{ url }} 并失败并显示 404。 您需要使用新的 attr 语法(vue 1.0):

详细

<img v-bind:src="url" />

shorthand

<img :src="url" />