[Vue warn]: Invalid prop: type check failed for prop “src“. Expected String, Object, got Module

环境

Laravel8 + Vue2.x + Vuetify2.x

报错

<template>
  <v-list-item class="mb-0 justify-space-between pl-3">
    <v-list-item-avatar>
      <v-img
        :src="require('../../../assets/vmd.svg')"
      />
    </v-list-item-avatar>

    <v-list-item-content class="pl-3">
      <v-list-item-title class="text-h6">
        <strong class="mr-1 font-weight-black">{{app.title}}</strong>

        <span class="primary--text">FREE</span>
      </v-list-item-title>
    </v-list-item-content>
  </v-list-item>
</template>

报错:[Vue warn]: Invalid prop: type check failed for prop “src”. Expected String, Object, got Module,
[Vue warn]: Invalid prop: type check failed for prop “src“. Expected String, Object, got Module

调试

console.log(require('../../../assets/vmd.svg'));

[Vue warn]: Invalid prop: type check failed for prop “src“. Expected String, Object, got Module

解决办法

改为 require(’…/…/…/assets/vmd.svg’).default 即可:

<template>
  <v-list-item class="mb-0 justify-space-between pl-3">
    <v-list-item-avatar>
      <v-img
        :src="require('../../../assets/vmd.svg').default"
      />
    </v-list-item-avatar>

    <v-list-item-content class="pl-3">
      <v-list-item-title class="text-h6">
        <strong class="mr-1 font-weight-black">{{app.title}}</strong>

        <span class="primary--text">FREE</span>
      </v-list-item-title>
    </v-list-item-content>
  </v-list-item>
</template>

总结

应该是 laravel-mix 的问题,应该还有其它解决办法,尚未知。

上一篇:PuTTY 错误:“expected key exchange group packet


下一篇:Delphi编译错误代码翻译表