Linking to images referenced in vuex store in Vue.js

后端 未结 1 367
伪装坚强ぢ
伪装坚强ぢ 2021-01-05 21:31

I am using Vue.js for the first time so apologies if this is a basic question – I have set up the vue project with the vue-cli, vue-router

相关标签:
1条回答
  • 2021-01-05 22:01

    :src='student.image' (v-binding) is executed at runtime, but webpack aliases work in compile time. So you have to wrap the aliased file path in require.

    {
      id: 1,
      name: 'Advik',
      age: '19',
      studying: 'Physiotherapy',
      image: require('~@/assets/images/students/advik-1.png')
    }
    
    0 讨论(0)
提交回复
热议问题