my vue app, make img-src binding with alias. it running direct use.
<img src="@/assets/search.png" />
But, this code make component, alias not resolve.
<template>
<div class="button-card">
<img :src="src">
</div>
</template>
<script>
export default {
name: 'Button Card',
props: {
src: {
type: String,
},
},
};
</script>
With component build result html:
<div class="button-card">
<img src="@/assets/search.png">
<!-- should be with resolve: src/assets/search.png -->
</div>
Webpack alias define config:
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
Why this code not resolve? or what can I do to make it run?